Unhide on sync when no pending operations

pull/147/head
M66B 6 years ago
parent d2961dbf75
commit 1e0d4d68e3

@ -59,6 +59,11 @@ public interface DaoOperation {
" AND (:name IS NULL OR operation.name = :name)") " AND (:name IS NULL OR operation.name = :name)")
int getOperationCount(long folder, String name); int getOperationCount(long folder, String name);
@Query("SELECT COUNT(id) FROM operation" +
" WHERE folder = :folder" +
" AND message = :message")
int getOperationCount(long folder, long message);
@Query("UPDATE operation SET error = :error WHERE id = :id") @Query("UPDATE operation SET error = :error WHERE id = :id")
int setOperationError(long id, String error); int setOperationError(long id, String error);

@ -982,7 +982,7 @@ public class ServiceSynchronize extends LifecycleService {
db.beginTransaction(); db.beginTransaction();
message = synchronizeMessage( message = synchronizeMessage(
ServiceSynchronize.this, ServiceSynchronize.this,
folder, ifolder, (IMAPMessage) imessage, false, false); folder, ifolder, (IMAPMessage) imessage, false);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();
@ -1069,7 +1069,7 @@ public class ServiceSynchronize extends LifecycleService {
db.beginTransaction(); db.beginTransaction();
message = synchronizeMessage( message = synchronizeMessage(
ServiceSynchronize.this, ServiceSynchronize.this,
folder, ifolder, (IMAPMessage) e.getMessage(), false, false); folder, ifolder, (IMAPMessage) e.getMessage(), false);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();
@ -2136,7 +2136,7 @@ public class ServiceSynchronize extends LifecycleService {
EntityMessage message = synchronizeMessage( EntityMessage message = synchronizeMessage(
this, this,
folder, ifolder, (IMAPMessage) isub[j], folder, ifolder, (IMAPMessage) isub[j],
false, true); false);
ids[from + j] = message.id; ids[from + j] = message.id;
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
@ -2219,7 +2219,7 @@ public class ServiceSynchronize extends LifecycleService {
static EntityMessage synchronizeMessage( static EntityMessage synchronizeMessage(
Context context, Context context,
EntityFolder folder, IMAPFolder ifolder, IMAPMessage imessage, EntityFolder folder, IMAPFolder ifolder, IMAPMessage imessage,
boolean browsed, boolean full) throws MessagingException, IOException { boolean browsed) throws MessagingException, IOException {
long uid = ifolder.getUID(imessage); long uid = ifolder.getUID(imessage);
if (imessage.isExpunged()) { if (imessage.isExpunged()) {
@ -2412,7 +2412,7 @@ public class ServiceSynchronize extends LifecycleService {
" keywords=" + TextUtils.join(" ", keywords)); " keywords=" + TextUtils.join(" ", keywords));
} }
if (message.ui_hide && full) { if (message.ui_hide && db.operation().getOperationCount(folder.id, message.id) == 0) {
update = true; update = true;
message.ui_hide = false; message.ui_hide = false;
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide"); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide");

@ -220,7 +220,7 @@ public class ViewModelBrowse extends ViewModel {
if (message == null) { if (message == null) {
message = ServiceSynchronize.synchronizeMessage( message = ServiceSynchronize.synchronizeMessage(
state.context, state.context,
folder, state.ifolder, (IMAPMessage) isub[j], true, false); folder, state.ifolder, (IMAPMessage) isub[j], true);
count++; count++;
} }
db.message().setMessageFound(message.account, message.thread); db.message().setMessageFound(message.account, message.thread);

Loading…
Cancel
Save