Skip saving on add/remove attachments

pull/178/head
M66B 6 years ago
parent fbf421fc23
commit 30333cc356

@ -1948,10 +1948,10 @@ public class FragmentCompose extends FragmentBase {
etBody.setText(body); etBody.setText(body);
if (start < body.length()) if (start < body.length())
etBody.setSelection(start); etBody.setSelection(start);
}
// Save text & update remote draft // Save text with image
onAction(R.id.action_save, "addattachment"); onAction(R.id.action_save, "image");
}
} }
@Override @Override
@ -3619,8 +3619,6 @@ public class FragmentCompose extends FragmentBase {
db.attachment().liveAttachments(data.draft.id).observe(getViewLifecycleOwner(), db.attachment().liveAttachments(data.draft.id).observe(getViewLifecycleOwner(),
new Observer<List<EntityAttachment>>() { new Observer<List<EntityAttachment>>() {
private int last_available = 0;
@Override @Override
public void onChanged(@Nullable List<EntityAttachment> attachments) { public void onChanged(@Nullable List<EntityAttachment> attachments) {
if (attachments == null) if (attachments == null)
@ -3629,28 +3627,18 @@ public class FragmentCompose extends FragmentBase {
adapter.set(attachments); adapter.set(attachments);
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE); grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
int available = 0;
boolean downloading = false; boolean downloading = false;
boolean inline_images = false; boolean inline_images = false;
for (EntityAttachment attachment : attachments) { for (EntityAttachment attachment : attachments) {
if (attachment.encryption != null) if (attachment.encryption != null)
continue; continue;
if (attachment.available)
available++;
if (attachment.progress != null) if (attachment.progress != null)
downloading = true; downloading = true;
if (attachment.isInline() && attachment.isImage()) if (attachment.isInline() && attachment.isImage())
inline_images = true; inline_images = true;
} }
Log.i("Attachments=" + attachments.size() + Log.i("Attachments=" + attachments.size() + " downloading=" + downloading);
" available=" + available + " downloading=" + downloading);
// Attachment deleted: update remote draft
if (available < last_available)
onAction(R.id.action_save, "delattachment");
last_available = available;
rvAttachment.setTag(downloading); rvAttachment.setTag(downloading);
checkInternet(); checkInternet();

Loading…
Cancel
Save