mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 01:31:02 +00:00
Confirm deletion
This commit is contained in:
parent
88c3fedd93
commit
fab43da52f
5 changed files with 37 additions and 2 deletions
|
@ -157,7 +157,9 @@
|
||||||
"status.bookmark" = "Bookmark";
|
"status.bookmark" = "Bookmark";
|
||||||
"status.content-warning-abbreviation" = "CW";
|
"status.content-warning-abbreviation" = "CW";
|
||||||
"status.delete" = "Delete";
|
"status.delete" = "Delete";
|
||||||
|
"status.delete.confirm" = "Are you sure you want to delete this post?";
|
||||||
"status.delete-and-redraft" = "Delete & re-draft";
|
"status.delete-and-redraft" = "Delete & re-draft";
|
||||||
|
"status.delete-and-redraft.confirm" = "Are you sure you want to delete this post and re-draft it? Favorites and boosts will be lost, and replies to the original post will be orphaned.";
|
||||||
"status.mute" = "Mute conversation";
|
"status.mute" = "Mute conversation";
|
||||||
"status.pin" = "Pin on profile";
|
"status.pin" = "Pin on profile";
|
||||||
"status.pinned-post" = "Pinned post";
|
"status.pinned-post" = "Pinned post";
|
||||||
|
|
|
@ -307,6 +307,8 @@ private extension TableViewController {
|
||||||
present(attachmentViewModel: attachmentViewModel, statusViewModel: statusViewModel)
|
present(attachmentViewModel: attachmentViewModel, statusViewModel: statusViewModel)
|
||||||
case let .compose(inReplyToViewModel, redraft):
|
case let .compose(inReplyToViewModel, redraft):
|
||||||
compose(inReplyToViewModel: inReplyToViewModel, redraft: redraft)
|
compose(inReplyToViewModel: inReplyToViewModel, redraft: redraft)
|
||||||
|
case let .confirmDelete(statusViewModel, redraft):
|
||||||
|
confirmDelete(statusViewModel: statusViewModel, redraft: redraft)
|
||||||
case let .report(reportViewModel):
|
case let .report(reportViewModel):
|
||||||
report(reportViewModel: reportViewModel)
|
report(reportViewModel: reportViewModel)
|
||||||
}
|
}
|
||||||
|
@ -389,6 +391,29 @@ private extension TableViewController {
|
||||||
present(navigationController, animated: true)
|
present(navigationController, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func confirmDelete(statusViewModel: StatusViewModel, redraft: Bool) {
|
||||||
|
let alertController = UIAlertController(
|
||||||
|
title: nil,
|
||||||
|
message: redraft
|
||||||
|
? NSLocalizedString("status.delete-and-redraft.confirm", comment: "")
|
||||||
|
: NSLocalizedString("status.delete.confirm", comment: ""),
|
||||||
|
preferredStyle: .alert)
|
||||||
|
|
||||||
|
let deleteAction = UIAlertAction(
|
||||||
|
title: redraft
|
||||||
|
? NSLocalizedString("status.delete-and-redraft", comment: "")
|
||||||
|
: NSLocalizedString("status.delete", comment: ""),
|
||||||
|
style: .destructive) { _ in
|
||||||
|
redraft ? statusViewModel.deleteAndRedraft() : statusViewModel.delete()
|
||||||
|
}
|
||||||
|
let cancelAction = UIAlertAction(title: NSLocalizedString("cancel", comment: ""), style: .cancel) { _ in }
|
||||||
|
|
||||||
|
alertController.addAction(deleteAction)
|
||||||
|
alertController.addAction(cancelAction)
|
||||||
|
|
||||||
|
present(alertController, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
func set(expandAllState: ExpandAllState) {
|
func set(expandAllState: ExpandAllState) {
|
||||||
switch expandAllState {
|
switch expandAllState {
|
||||||
case .hidden:
|
case .hidden:
|
||||||
|
|
|
@ -9,6 +9,7 @@ public enum CollectionItemEvent {
|
||||||
case navigation(Navigation)
|
case navigation(Navigation)
|
||||||
case attachment(AttachmentViewModel, StatusViewModel)
|
case attachment(AttachmentViewModel, StatusViewModel)
|
||||||
case compose(inReplyTo: StatusViewModel?, redraft: Status?)
|
case compose(inReplyTo: StatusViewModel?, redraft: Status?)
|
||||||
|
case confirmDelete(StatusViewModel, redraft: Bool)
|
||||||
case report(ReportViewModel)
|
case report(ReportViewModel)
|
||||||
case share(URL)
|
case share(URL)
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,6 +254,13 @@ public extension StatusViewModel {
|
||||||
.eraseToAnyPublisher())
|
.eraseToAnyPublisher())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func confirmDelete(redraft: Bool) {
|
||||||
|
eventsSubject.send(
|
||||||
|
Just(.confirmDelete(self, redraft: redraft))
|
||||||
|
.setFailureType(to: Error.self)
|
||||||
|
.eraseToAnyPublisher())
|
||||||
|
}
|
||||||
|
|
||||||
func delete() {
|
func delete() {
|
||||||
eventsSubject.send(
|
eventsSubject.send(
|
||||||
statusService.delete()
|
statusService.delete()
|
||||||
|
|
|
@ -431,13 +431,13 @@ private extension StatusView {
|
||||||
title: NSLocalizedString("status.delete", comment: ""),
|
title: NSLocalizedString("status.delete", comment: ""),
|
||||||
image: UIImage(systemName: "trash"),
|
image: UIImage(systemName: "trash"),
|
||||||
attributes: .destructive) { _ in
|
attributes: .destructive) { _ in
|
||||||
viewModel.delete()
|
viewModel.confirmDelete(redraft: false)
|
||||||
},
|
},
|
||||||
UIAction(
|
UIAction(
|
||||||
title: NSLocalizedString("status.delete-and-redraft", comment: ""),
|
title: NSLocalizedString("status.delete-and-redraft", comment: ""),
|
||||||
image: UIImage(systemName: "trash.circle"),
|
image: UIImage(systemName: "trash.circle"),
|
||||||
attributes: .destructive) { _ in
|
attributes: .destructive) { _ in
|
||||||
viewModel.deleteAndRedraft()
|
viewModel.confirmDelete(redraft: true)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue