handle saving draft when attachment not uploaded

closes sk22#402
This commit is contained in:
sk 2023-02-06 14:31:53 +01:00
parent dae347a29f
commit 12558c3c18
2 changed files with 10 additions and 1 deletions

View File

@ -1248,7 +1248,14 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
}
private void confirmDiscardDraftAndFinish(){
new M3AlertDialogBuilder(getActivity())
boolean attachmentsPending = attachments.stream().anyMatch(att -> att.state != AttachmentUploadState.DONE);
if (attachmentsPending) new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.sk_unfinished_attachments)
.setMessage(R.string.sk_unfinished_attachments_message)
.setPositiveButton(R.string.edit, (d, w) -> {})
.setNegativeButton(R.string.discard, (d, w) -> Nav.finish(this))
.show();
else new M3AlertDialogBuilder(getActivity())
.setTitle(editingStatus != null ? R.string.sk_confirm_save_changes : R.string.sk_confirm_save_draft)
.setPositiveButton(R.string.save, (d, w) -> {
updateScheduledAt(scheduledAt == null ? getDraftInstant() : scheduledAt);

View File

@ -256,4 +256,6 @@
<string name="sk_expand">Expand</string>
<string name="sk_collapse">Collapse</string>
<string name="sk_settings_collapse_long_posts">Collapse very long posts</string>
<string name="sk_unfinished_attachments">Fix attachments?</string>
<string name="sk_unfinished_attachments_message">Some attachments havent finished uploading.</string>
</resources>