mirror of https://github.com/M66B/FairEmail.git
Auto reload on body/attachment
This commit is contained in:
parent
78a739de13
commit
0c8206ddc9
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -132,6 +132,8 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
|||
long id = args.getLong("id");
|
||||
long mid = args.getLong("message");
|
||||
|
||||
Long reload = null;
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
@ -140,6 +142,13 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
|||
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;
|
||||
|
@ -151,7 +160,10 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
|||
db.endTransaction();
|
||||
}
|
||||
|
||||
ServiceSynchronize.eval(context, "attachment");
|
||||
if (reload == null)
|
||||
ServiceSynchronize.eval(context, "image");
|
||||
else
|
||||
ServiceSynchronize.reload(context, reload, true, "image");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -5992,6 +5992,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
protected Void onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
|
||||
Long reload = null;
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
@ -6008,6 +6010,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
if (account == null)
|
||||
return null;
|
||||
|
||||
if (!"connected".equals(account.state))
|
||||
reload = account.id;
|
||||
|
||||
if (message.ui_unsnoozed)
|
||||
db.message().setMessageUnsnoozed(message.id, false);
|
||||
|
||||
|
@ -6034,7 +6039,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
db.endTransaction();
|
||||
}
|
||||
|
||||
ServiceSynchronize.eval(context, "expand");
|
||||
if (reload == null)
|
||||
ServiceSynchronize.eval(context, "expand");
|
||||
else
|
||||
ServiceSynchronize.reload(context, reload, true, "expand");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue