Show prompt if there are server-side changes to post

This commit is contained in:
Angelo Stavrow 2020-11-26 15:01:12 -05:00
parent 7cb7fa3017
commit 5ca32ddcfc
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 32 additions and 22 deletions

View File

@ -66,7 +66,7 @@ struct ContentView: View {
}
ToolbarItem(placement: .status) {
if let selectedPost = model.selectedPost {
PostStatusBadgeView(post: selectedPost)
PostEditorStatusToolbarView(post: selectedPost)
}
}
ToolbarItemGroup(placement: .primaryAction) {

View File

@ -11,16 +11,21 @@ struct PostEditorStatusToolbarView: View {
PostStatusBadgeView(post: post)
#else
HStack {
HStack {
Text("⚠️ Newer copy on server. Replace local copy?")
.font(.callout)
.foregroundColor(.secondary)
Button(action: {
model.updateFromServer(post: post)
}, label: {
Image(systemName: "square.and.arrow.down")
})
}
.padding(.horizontal)
.background(Color.primary.opacity(0.1))
.clipShape(Capsule())
.padding(.trailing)
PostStatusBadgeView(post: post)
.padding(.trailing)
Text("⚠️ Newer copy on server. Replace local copy?")
.font(.callout)
.foregroundColor(.secondary)
Button(action: {
model.updateFromServer(post: post)
}, label: {
Image(systemName: "square.and.arrow.down")
})
}
#endif
} else if post.wasDeletedFromServer && post.status != PostStatus.local.rawValue {
@ -28,19 +33,24 @@ struct PostEditorStatusToolbarView: View {
PostStatusBadgeView(post: post)
#else
HStack {
HStack {
Text("⚠️ Post deleted from server. Delete local copy?")
.font(.callout)
.foregroundColor(.secondary)
Button(action: {
model.selectedPost = nil
DispatchQueue.main.async {
model.posts.remove(post)
}
}, label: {
Image(systemName: "trash")
})
}
.padding(.horizontal)
.background(Color.primary.opacity(0.1))
.clipShape(Capsule())
.padding(.trailing)
PostStatusBadgeView(post: post)
.padding(.trailing)
Text("⚠️ Post deleted from server. Delete local copy?")
.font(.callout)
.foregroundColor(.secondary)
Button(action: {
model.selectedPost = nil
DispatchQueue.main.async {
model.posts.remove(post)
}
}, label: {
Image(systemName: "trash")
})
}
#endif
} else {