Batch notify new messages

pull/153/head
M66B 6 years ago
parent 68cf08526e
commit 3c63f4bfe3

@ -89,6 +89,11 @@ public interface DaoFolder {
" AND folder.type = '" + EntityFolder.DRAFTS + "'")
LiveData<EntityFolder> livePrimaryDrafts();
@Query("SELECT COUNT(id) FROM folder" +
" WHERE sync_state = 'syncing'" +
" AND folder.type <> '" + EntityFolder.OUTBOX + "'")
LiveData<Integer> liveSynchronizing();
@Query("SELECT folder.*" +
", account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(message.id) AS messages" +

@ -128,7 +128,20 @@ public class ServiceSynchronize extends LifecycleService {
}
});
db.message().liveUnseenNotify().observe(this, new Observer<List<TupleMessageEx>>() {
final TwoStateOwner cowner = new TwoStateOwner(this);
db.folder().liveSynchronizing().observe(this, new Observer<Integer>() {
@Override
public void onChanged(Integer count) {
Log.i("Synchronizing folders=" + count);
if (count == 0)
cowner.start();
else
cowner.stop();
}
});
db.message().liveUnseenNotify().observe(cowner, new Observer<List<TupleMessageEx>>() {
@Override
public void onChanged(List<TupleMessageEx> messages) {
Core.notifyMessages(ServiceSynchronize.this, messages);

Loading…
Cancel
Save