Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F15047087
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/Shared/PostList/PostListFilteredView.swift b/Shared/PostList/PostListFilteredView.swift
index aceb999..cf09a4e 100644
--- a/Shared/PostList/PostListFilteredView.swift
+++ b/Shared/PostList/PostListFilteredView.swift
@@ -1,61 +1,61 @@
import SwiftUI
struct PostListFilteredView: View {
@EnvironmentObject var model: WriteFreelyModel
var fetchRequest: FetchRequest<WFAPost>
init(filter: String?, showAllPosts: Bool) {
if showAllPosts {
fetchRequest = FetchRequest<WFAPost>(
entity: WFAPost.entity(),
sortDescriptors: [NSSortDescriptor(key: "createdDate", ascending: false)]
)
} else {
if let filter = filter {
fetchRequest = FetchRequest<WFAPost>(
entity: WFAPost.entity(),
sortDescriptors: [NSSortDescriptor(key: "createdDate", ascending: false)],
predicate: NSPredicate(format: "collectionAlias == %@", filter)
)
} else {
fetchRequest = FetchRequest<WFAPost>(
entity: WFAPost.entity(),
sortDescriptors: [NSSortDescriptor(key: "createdDate", ascending: false)],
predicate: NSPredicate(format: "collectionAlias == nil")
)
}
}
}
var body: some View {
List {
ForEach(fetchRequest.wrappedValue, id: \.self) { post in
NavigationLink(
destination: PostEditorView(post: post),
tag: post,
selection: $model.selectedPost
) {
PostCellView(post: post)
}
- }.onDelete(perform: { indexSet in
+ .deleteDisabled(post.status != PostStatus.local.rawValue)
+ }
+ .onDelete(perform: { indexSet in
for index in indexSet {
let post = fetchRequest.wrappedValue[index]
- if post.status == PostStatus.local.rawValue {
- delete(post)
- }
+ delete(post)
}
})
}
}
func delete(_ post: WFAPost) {
model.posts.remove(post)
}
}
struct PostListFilteredView_Previews: PreviewProvider {
static var previews: some View {
return PostListFilteredView(filter: nil, showAllPosts: false)
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Dec 2, 7:24 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3831633
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment