Auto reload on body/attachment

This commit is contained in:
M66B
2022-01-14 20:49:25 +01:00
parent 78a739de13
commit 0c8206ddc9
3 changed files with 35 additions and 3 deletions

View File

@@ -291,6 +291,8 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
long id = args.getLong("id");
long mid = args.getLong("message");
Long reload = null;
DB db = DB.getInstance(context);
try {
db.beginTransaction();
@@ -299,6 +301,13 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
if (message == null || message.uid == null)
return null;
EntityAccount account = db.account().getAccount(message.id);
if (account == null)
return null;
if (!"connected".equals(account.state))
reload = account.id;
EntityAttachment attachment = db.attachment().getAttachment(id);
if (attachment == null || attachment.progress != null || attachment.available)
return null;
@@ -310,7 +319,10 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
db.endTransaction();
}
ServiceSynchronize.eval(context, "attachment");
if (reload == null)
ServiceSynchronize.eval(context, "attachment");
else
ServiceSynchronize.reload(context, reload, true, "attachment");
return null;
}