Check if operation before message update

pull/160/head
M66B 5 years ago
parent a49f20db83
commit 1053ba3ac1

@ -1585,7 +1585,8 @@ class Core {
} }
} }
if (!message.seen.equals(seen) || !message.seen.equals(message.ui_seen)) { if ((!message.seen.equals(seen) || !message.ui_seen.equals(seen)) &&
db.operation().getOperationCount(folder.id, message.id, EntityOperation.SEEN) == 0) {
update = true; update = true;
message.seen = seen; message.seen = seen;
message.ui_seen = seen; message.ui_seen = seen;
@ -1594,7 +1595,8 @@ class Core {
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen);
} }
if (!message.answered.equals(answered) || !message.answered.equals(message.ui_answered)) { if ((!message.answered.equals(answered) || !message.ui_answered.equals(message.answered)) &&
db.operation().getOperationCount(folder.id, message.id, EntityOperation.ANSWERED) == 0) {
if (!answered && message.ui_answered && ifolder.getPermanentFlags().contains(Flags.Flag.ANSWERED)) { if (!answered && message.ui_answered && ifolder.getPermanentFlags().contains(Flags.Flag.ANSWERED)) {
// This can happen when the answered operation was skipped because the message was moving // This can happen when the answered operation was skipped because the message was moving
answered = true; answered = true;
@ -1606,7 +1608,8 @@ class Core {
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " answered=" + answered); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " answered=" + answered);
} }
if (!message.flagged.equals(flagged) || !message.flagged.equals(message.ui_flagged)) { if ((!message.flagged.equals(flagged) || !message.ui_flagged.equals(flagged)) &&
db.operation().getOperationCount(folder.id, message.id, EntityOperation.FLAG) == 0) {
update = true; update = true;
message.flagged = flagged; message.flagged = flagged;
message.ui_flagged = flagged; message.ui_flagged = flagged;

@ -97,14 +97,20 @@ public interface DaoOperation {
@Query("SELECT COUNT(id) FROM operation" + @Query("SELECT COUNT(id) FROM operation" +
" WHERE folder = :folder" + " WHERE folder = :folder" +
" AND (:name IS NULL OR operation.name = :name)") " AND (:name IS NULL OR name = :name)")
int getOperationCount(long folder, String name); int getOperationCount(long folder, String name);
@Query("SELECT COUNT(id) FROM operation" + @Query("SELECT COUNT(id) FROM operation" +
" WHERE folder = :folder" + " WHERE folder = :folder" +
" AND message = :message") " AND message = :message")
int getOperationCount(long folder, long message); int getOperationCount(long folder, long message);
@Query("SELECT COUNT(id) FROM operation" +
" WHERE folder = :folder" +
" AND message = :message" +
" AND name = :name")
int getOperationCount(long folder, long message, String name);
@Query("UPDATE operation SET state = :state WHERE id = :id") @Query("UPDATE operation SET state = :state WHERE id = :id")
int setOperationState(long id, String state); int setOperationState(long id, String state);

Loading…
Cancel
Save