POP3: fixed hidding incorrect messages

pull/212/head
M66B 2 years ago
parent 1aa1305d34
commit 30204e3c16

@ -3430,8 +3430,8 @@ class Core {
} }
if (account.max_messages != null && !account.leave_on_device) { if (account.max_messages != null && !account.leave_on_device) {
int hidden = db.message().setMessagesUiHide(folder.id, Math.abs(account.max_messages) + flagged); int hidden = db.message().setMessagesUiHide(folder.id, Math.abs(account.max_messages) + flagged, reversed);
int deleted = db.message().deleteMessagesKeep(folder.id, Math.abs(account.max_messages) + flagged + 100); int deleted = db.message().deleteMessagesKeep(folder.id, Math.abs(account.max_messages) + flagged + 100, reversed);
EntityLog.log(context, account.name + " POP" + EntityLog.log(context, account.name + " POP" +
" cleanup max=" + account.max_messages + "" + " cleanup max=" + account.max_messages + "" +
" hidden=" + hidden + " deleted=" + deleted); " hidden=" + hidden + " deleted=" + deleted);

@ -792,9 +792,9 @@ public interface DaoMessage {
" AND id NOT IN (" + " AND id NOT IN (" +
" SELECT id FROM message" + " SELECT id FROM message" +
" WHERE folder = :folder" + " WHERE folder = :folder" +
" ORDER BY received DESC" + " ORDER BY CASE WHEN :reversed THEN -received ELSE received END DESC" +
" LIMIT :keep)") " LIMIT :keep)")
int setMessagesUiHide(long folder, int keep); int setMessagesUiHide(long folder, int keep, boolean reversed);
@Transaction @Transaction
@Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id AND NOT (ui_ignored IS :ui_ignored)") @Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id AND NOT (ui_ignored IS :ui_ignored)")
@ -1018,7 +1018,7 @@ public interface DaoMessage {
" AND id NOT IN (" + " AND id NOT IN (" +
" SELECT id FROM message" + " SELECT id FROM message" +
" WHERE folder = :folder" + " WHERE folder = :folder" +
" ORDER BY received DESC" + " ORDER BY CASE WHEN :reversed THEN -received ELSE received END DESC" +
" LIMIT :keep)") " LIMIT :keep)")
int deleteMessagesKeep(long folder, int keep); int deleteMessagesKeep(long folder, int keep, boolean reversed);
} }
Loading…
Cancel
Save