From 8810639c6422dd3d7a12047f9765cda5208614f4 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 21 Apr 2019 07:53:58 +0200 Subject: [PATCH] Undo selection on hiding message --- .../main/java/eu/faircode/email/DaoMessage.java | 6 ++++++ .../java/eu/faircode/email/FragmentMessages.java | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 4e2f15f1da..24861a79e4 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -147,6 +147,12 @@ public interface DaoMessage { ", CASE WHEN folder.type = '" + EntityFolder.ARCHIVE + "' THEN 1 ELSE 0 END") DataSource.Factory pagedThread(long account, String thread, Long id, boolean debug); + @Query("SELECT message.id FROM folder" + + " JOIN message ON message.folder = folder.id" + + " WHERE CASE WHEN :folder IS NULL THEN folder.unified ELSE folder.id = :folder END" + + " AND ui_hide") + LiveData> liveHidden(Long folder); + @Query("SELECT id FROM message" + " WHERE account = :account" + " AND thread = :thread" + diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 47e41a4a5d..53f74e9680 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -1754,6 +1754,14 @@ public class FragmentMessages extends FragmentBase { swipeRefresh.setRefreshing(refreshing); } }); + db.message().liveHidden(null).observe(getViewLifecycleOwner(), new Observer>() { + @Override + public void onChanged(List ids) { + if (ids != null && selectionTracker != null) + for (long id : ids) + selectionTracker.deselect(id); + } + }); break; case FOLDER: @@ -1793,6 +1801,14 @@ public class FragmentMessages extends FragmentBase { swipeRefresh.setRefreshing(refreshing); } }); + db.message().liveHidden(folder).observe(getViewLifecycleOwner(), new Observer>() { + @Override + public void onChanged(List ids) { + if (ids != null && selectionTracker != null) + for (long id : ids) + selectionTracker.deselect(id); + } + }); break; case THREAD: