Check if operation before message update

This commit is contained in:
M66B 2019-08-03 20:44:30 +02:00
parent a49f20db83
commit 1053ba3ac1
2 changed files with 14 additions and 5 deletions

View File

@ -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;

View File

@ -97,14 +97,20 @@ 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" +
" WHERE folder = :folder" +
" AND message = :message")
" 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);