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;
message.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);
}
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)) {
// This can happen when the answered operation was skipped because the message was moving
answered = true;
@ -1606,7 +1608,8 @@ class Core {
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;
message.flagged = flagged;
message.ui_flagged = flagged;

@ -97,7 +97,7 @@ public interface DaoOperation {
@Query("SELECT COUNT(id) FROM operation" +
" WHERE folder = :folder" +
" AND (:name IS NULL OR operation.name = :name)")
" AND (:name IS NULL OR name = :name)")
int getOperationCount(long folder, String name);
@Query("SELECT COUNT(id) FROM operation" +
@ -105,6 +105,12 @@ public interface DaoOperation {
" AND message = :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")
int setOperationState(long id, String state);

Loading…
Cancel
Save