1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 20:54:34 +00:00

Notify new message in message view

This commit is contained in:
M66B 2019-02-27 18:52:38 +00:00
parent 917c02f46d
commit fdd304add1
4 changed files with 13 additions and 12 deletions

View file

@ -262,7 +262,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
getSupportFragmentManager().addOnBackStackChangedListener(this); getSupportFragmentManager().addOnBackStackChangedListener(this);
DB.getInstance(this).account().liveAccountsEx().observe(this, new Observer<List<TupleAccountEx>>() { DB db = DB.getInstance(this);
db.account().liveAccountsEx().observe(this, new Observer<List<TupleAccountEx>>() {
private List<TupleAccountEx> last = new ArrayList<>(); private List<TupleAccountEx> last = new ArrayList<>();
@Override @Override
@ -351,6 +353,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
}); });
db.message().liveUnseenNotify().observe(this, new Observer<List<TupleMessageEx>>() {
@Override
public void onChanged(List<TupleMessageEx> messages) {
Core.notify(ActivityView.this, messages);
}
});
if (getSupportFragmentManager().getFragments().size() == 0 && !getIntent().hasExtra(Intent.EXTRA_PROCESS_TEXT)) if (getSupportFragmentManager().getFragments().size() == 0 && !getIntent().hasExtra(Intent.EXTRA_PROCESS_TEXT))
init(); init();

View file

@ -207,7 +207,7 @@ public interface DaoMessage {
" WHERE message.id = :id") " WHERE message.id = :id")
LiveData<TupleMessageEx> liveMessage(long id); LiveData<TupleMessageEx> liveMessage(long id);
String notify = "SELECT message.*" + @Query("SELECT message.*" +
", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" + ", account.name AS accountName, IFNULL(identity.color, account.color) AS accountColor, account.notify AS accountNotify" +
", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType" +
", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" +
@ -227,14 +227,9 @@ public interface DaoMessage {
" AND NOT message.ui_seen" + " AND NOT message.ui_seen" +
" AND NOT message.ui_hide" + " AND NOT message.ui_hide" +
" AND NOT message.ui_ignored" + " AND NOT message.ui_ignored" +
" ORDER BY message.received"; " ORDER BY message.received")
@Query(notify)
LiveData<List<TupleMessageEx>> liveUnseenNotify(); LiveData<List<TupleMessageEx>> liveUnseenNotify();
@Query(notify)
List<TupleMessageEx> getUnseenNotify();
@Query("SELECT COUNT(message.id) FROM message" + @Query("SELECT COUNT(message.id) FROM message" +
" JOIN account ON account.id = message.account" + " JOIN account ON account.id = message.account" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +

View file

@ -126,7 +126,7 @@ public class ServiceSynchronize extends LifecycleService {
db.message().liveUnseenNotify().observe(this, new Observer<List<TupleMessageEx>>() { db.message().liveUnseenNotify().observe(this, new Observer<List<TupleMessageEx>>() {
@Override @Override
public void onChanged(final List<TupleMessageEx> messages) { public void onChanged(List<TupleMessageEx> messages) {
Core.notify(ServiceSynchronize.this, messages); Core.notify(ServiceSynchronize.this, messages);
} }
}); });

View file

@ -281,9 +281,6 @@ public class ServiceUI extends IntentService {
// Synchronize messages // Synchronize messages
Core.onSynchronizeMessages(this, account, folder, (IMAPFolder) ifolder, folder.getSyncArgs(), new Core.State()); Core.onSynchronizeMessages(this, account, folder, (IMAPFolder) ifolder, folder.getSyncArgs(), new Core.State());
// Notify new messages
Core.notify(this, db.message().getUnseenNotify());
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
Core.reportError(this, account, folder, ex); Core.reportError(this, account, folder, ex);