Mark identical messages read/unread

This commit is contained in:
M66B 2022-12-14 17:00:43 +01:00
parent 4866510857
commit 7b3b90461f
4 changed files with 9 additions and 8 deletions

View File

@ -8386,7 +8386,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return null;
List<EntityMessage> messages =
db.message().getMessagesBySimilarity(message.account, message.id, message.msgid);
db.message().getMessagesBySimilarity(message.account, message.id, message.msgid, message.hash);
if (messages == null)
return null;

View File

@ -4825,7 +4825,7 @@ class Core {
}
if (syncSimilar && account.isGmail())
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid)) {
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid, message.hash)) {
if (similar.recent != message.recent) {
Log.i(folder.name + " Synchronize similar id=" + similar.id + " recent=" + message.recent);
db.message().setMessageRecent(similar.id, message.recent);

View File

@ -451,8 +451,9 @@ public interface DaoMessage {
" LEFT JOIN message AS base ON base.id = :id" +
" WHERE message.account = :account" +
" AND (message.id = :id" +
" OR (message.msgid = :msgid AND message.folder <> base.folder))")
List<EntityMessage> getMessagesBySimilarity(long account, long id, String msgid);
" OR (message.msgid = :msgid AND message.folder <> base.folder)" +
" OR (NOT :hash IS NULL AND message.hash IS :hash))")
List<EntityMessage> getMessagesBySimilarity(long account, long id, String msgid, String hash);
@Query("SELECT COUNT(*) FROM message" +
" WHERE folder = :folder" +

View File

@ -119,7 +119,7 @@ public class EntityOperation {
if (SEEN.equals(name)) {
boolean seen = jargs.getBoolean(0);
boolean ignore = jargs.optBoolean(1, true);
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid))
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid, message.hash))
if (similar.ui_seen != seen || similar.ui_ignored != ignore) {
db.message().setMessageUiSeen(similar.id, seen);
db.message().setMessageUiIgnored(similar.id, ignore);
@ -130,7 +130,7 @@ public class EntityOperation {
} else if (FLAG.equals(name)) {
boolean flagged = jargs.getBoolean(0);
Integer color = (jargs.length() > 1 && !jargs.isNull(1) ? jargs.getInt(1) : null);
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid))
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid, message.hash))
if (similar.ui_flagged != flagged || !Objects.equals(similar.color, color)) {
db.message().setMessageUiFlagged(similar.id, flagged, flagged ? color : null);
queue(context, similar.account, similar.folder, similar.id, name, jargs);
@ -147,7 +147,7 @@ public class EntityOperation {
return;
} else if (ANSWERED.equals(name)) {
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid)) {
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid, message.hash)) {
db.message().setMessageUiAnswered(similar.id, jargs.getBoolean(0));
queue(context, similar.account, similar.folder, similar.id, name, jargs);
}
@ -262,7 +262,7 @@ public class EntityOperation {
" auto read=" + autoread + " flag=" + autounflag + " importance=" + reset_importance);
if (autoread || autounflag || reset_importance)
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid)) {
for (EntityMessage similar : db.message().getMessagesBySimilarity(message.account, message.id, message.msgid, message.hash)) {
if (autoread)
queue(context, similar, SEEN, true);
if (autounflag)