mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Fetch collection name for post list cell if showing all posts
This commit is contained in:
parent
c55636df89
commit
6131f9e068
@ -3,9 +3,12 @@ import SwiftUI
|
||||
struct PostListFilteredView: View {
|
||||
@EnvironmentObject var model: WriteFreelyModel
|
||||
|
||||
@FetchRequest(entity: WFACollection.entity(), sortDescriptors: []) var collections: FetchedResults<WFACollection>
|
||||
var fetchRequest: FetchRequest<WFAPost>
|
||||
var showAllPosts: Bool
|
||||
|
||||
init(filter: String?, showAllPosts: Bool) {
|
||||
self.showAllPosts = showAllPosts
|
||||
if showAllPosts {
|
||||
fetchRequest = FetchRequest<WFAPost>(
|
||||
entity: WFAPost.entity(),
|
||||
@ -37,7 +40,16 @@ struct PostListFilteredView: View {
|
||||
tag: post,
|
||||
selection: $model.selectedPost
|
||||
) {
|
||||
PostCellView(post: post)
|
||||
if showAllPosts {
|
||||
if let collection = collections.filter { $0.alias == post.collectionAlias }.first {
|
||||
PostCellView(post: post, collectionName: collection.title)
|
||||
} else {
|
||||
let collectionName = model.account.server == "https://write.as" ? "Anonymous" : "Drafts"
|
||||
PostCellView(post: post, collectionName: collectionName)
|
||||
}
|
||||
} else {
|
||||
PostCellView(post: post)
|
||||
}
|
||||
}
|
||||
.deleteDisabled(post.status != PostStatus.local.rawValue)
|
||||
}
|
||||
|
@ -7,12 +7,12 @@
|
||||
<key>WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
Loading…
Reference in New Issue
Block a user