Scroll to top on fetch

This commit is contained in:
M66B 2020-05-05 21:13:05 +02:00
parent ede287098d
commit 53b8e1783a
1 changed files with 18 additions and 15 deletions

View File

@ -2371,19 +2371,7 @@ class Core {
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
} }
runRules(context, imessage, message, rules); runRules(context, imessage, account, folder, message, rules);
// Prepare scroll to top
if (!message.ui_seen && !message.ui_hide &&
message.received > account.created) {
Intent report = new Intent(ActivityView.ACTION_NEW_MESSAGE);
report.putExtra("folder", folder.id);
report.putExtra("unified", folder.unified);
Log.i("Report new id=" + message.id + " folder=" + folder.name + " unified=" + folder.unified);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(report);
}
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} catch (SQLiteConstraintException ex) { } catch (SQLiteConstraintException ex) {
@ -2526,7 +2514,7 @@ class Core {
db.message().updateMessage(message); db.message().updateMessage(message);
if (process) if (process)
runRules(context, imessage, message, rules); runRules(context, imessage, account, folder, message, rules);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
@ -2597,7 +2585,10 @@ class Core {
return null; return null;
} }
private static void runRules(Context context, Message imessage, EntityMessage message, List<EntityRule> rules) { private static void runRules(
Context context, Message imessage,
EntityAccount account, EntityFolder folder, EntityMessage message,
List<EntityRule> rules) {
if (!ActivityBilling.isPro(context)) if (!ActivityBilling.isPro(context))
return; return;
@ -2614,6 +2605,18 @@ class Core {
Log.e(ex); Log.e(ex);
db.message().setMessageError(message.id, Log.formatThrowable(ex)); db.message().setMessageError(message.id, Log.formatThrowable(ex));
} }
// Prepare scroll to top
if (!message.ui_seen && !message.ui_hide &&
message.received > account.created) {
Intent report = new Intent(ActivityView.ACTION_NEW_MESSAGE);
report.putExtra("folder", folder.id);
report.putExtra("unified", folder.unified);
Log.i("Report new id=" + message.id + " folder=" + folder.name + " unified=" + folder.unified);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(report);
}
} }
private static void updateContactInfo(Context context, final EntityFolder folder, final EntityMessage message) { private static void updateContactInfo(Context context, final EntityFolder folder, final EntityMessage message) {