From 8ddaa84bae02ee7148da643393178b1a8a17b017 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 3 Mar 2024 10:46:48 +0100 Subject: [PATCH] Unexposed implies unread --- app/src/main/java/eu/faircode/email/DaoAccount.java | 5 +++-- app/src/main/java/eu/faircode/email/DaoFolder.java | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoAccount.java b/app/src/main/java/eu/faircode/email/DaoAccount.java index b94605af25..e262fc5356 100644 --- a/app/src/main/java/eu/faircode/email/DaoAccount.java +++ b/app/src/main/java/eu/faircode/email/DaoAccount.java @@ -80,7 +80,8 @@ public interface DaoAccount { " JOIN folder ON folder.id = message.folder" + " WHERE message.account = account.id" + " AND folder.type <> '" + EntityFolder.OUTBOX + "'" + - " AND message.received > folder.last_view" + + " AND folder.count_unread" + + " AND NOT ui_seen AND message.received > folder.last_view" + " AND NOT ui_hide) AS unexposed" + " FROM account" + " LEFT JOIN folder AS drafts ON drafts.account = account.id AND drafts.type = '" + EntityFolder.DRAFTS + "'" + @@ -114,7 +115,7 @@ public interface DaoAccount { " ELSE message.id END)" + " FROM message" + " WHERE message.folder = folder.id" + - " AND message.received > folder.last_view" + + " AND NOT message.ui_seen AND message.received > folder.last_view" + " AND NOT ui_hide) AS unexposed" + " FROM account" + " JOIN folder ON folder.account = account.id" + diff --git a/app/src/main/java/eu/faircode/email/DaoFolder.java b/app/src/main/java/eu/faircode/email/DaoFolder.java index c2cb71462e..44dc34a55d 100644 --- a/app/src/main/java/eu/faircode/email/DaoFolder.java +++ b/app/src/main/java/eu/faircode/email/DaoFolder.java @@ -44,7 +44,7 @@ public interface DaoFolder { ", COUNT(DISTINCT message.id) AS messages" + ", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen THEN message.id ELSE NULL END) AS unseen" + - ", COUNT(DISTINCT CASE WHEN message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" + + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" + ", COUNT(DISTINCT CASE WHEN message.ui_flagged THEN message.id ELSE NULL END) AS flagged" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + " FROM folder" + @@ -85,7 +85,7 @@ public interface DaoFolder { ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + ", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" + - ", COUNT(DISTINCT CASE WHEN message.received > folder.last_view AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unexposed" + + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide AND message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" + ", COUNT(DISTINCT CASE WHEN message.ui_flagged AND NOT message.ui_hide THEN message.id ELSE NULL END) AS flagged" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + " FROM folder" + @@ -110,7 +110,7 @@ public interface DaoFolder { ", COUNT(DISTINCT message.id) AS messages" + ", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen THEN message.id ELSE NULL END) AS unseen" + - ", COUNT(DISTINCT CASE WHEN message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" + + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" + ", COUNT(DISTINCT CASE WHEN message.ui_flagged THEN message.id ELSE NULL END) AS flagged" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + " FROM folder" + @@ -144,7 +144,7 @@ public interface DaoFolder { ", COUNT(DISTINCT message.id) AS messages" + ", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen THEN message.id ELSE NULL END) AS unseen" + - ", COUNT(DISTINCT CASE WHEN message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" + + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND message.received > folder.last_view THEN message.id ELSE NULL END) AS unexposed" + ", COUNT(DISTINCT CASE WHEN message.ui_flagged THEN message.id ELSE NULL END) AS flagged" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + " FROM folder" + @@ -194,7 +194,7 @@ public interface DaoFolder { ", COUNT(DISTINCT folder.id) AS folders" + ", COUNT(message.id) AS messages" + ", SUM(CASE WHEN NOT message.ui_seen THEN 1 ELSE 0 END) AS unseen" + - ", SUM(CASE WHEN message.received > folder.last_view THEN 1 ELSE 0 END) AS unexposed" + + ", SUM(CASE WHEN NOT message.ui_seen AND message.received > folder.last_view THEN 1 ELSE 0 END) AS unexposed" + ", CASE WHEN folder.account IS NULL THEN folder.sync_state ELSE NULL END AS sync_state" + ", folder.color, COUNT (DISTINCT folder.color) AS colorCount" + " FROM folder" +