diff --git a/src/db.lisp b/src/db.lisp index 75795b8..6d78bcd 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -2759,29 +2759,32 @@ of (timeline, folder) pairs that has statuses marked for deletion." name" (cl-ppcre:regex-replace +folder-tag-prefix+ folder "")) -(defun max-status-id-subscribed-tag (tag) +(defun max-status-id-subscribed-tag (tag &key (include-ignored t)) (let* ((max-status-id-row (fetch-single (select (fields (:max :status-id)) (from +table-status+) (where (:= :folder (tag->folder-name tag)))))) - (max-status-id (second max-status-id-row)) - (max-ignored-status-id-row (fetch-single (select (fields (:max :status-id)) - (from +table-ignored-status+) - (where (:= :folder - (tag->folder-name tag)))))) - (max-ignored-status-id (second max-ignored-status-id-row))) - (or max-status-id - max-ignored-status-id))) + (max-status-id (second max-status-id-row))) + (if (not include-ignored) + max-status-id + (let* ((max-ignored-status-id-row (fetch-single (select (fields (:max :status-id)) + (from +table-ignored-status+) + (where (:= :folder + (tag->folder-name tag)))))) + (max-ignored-status-id (second max-ignored-status-id-row))) + (or max-status-id + max-ignored-status-id))))) (defun more-recent-tag-fetched-p (tag) "Returns the most recent message fetched that contains tag `tag', or nil if no such message exists" (when-let* ((row (fetch-from-id +table-subscribed-tag+ tag))) (let* ((last-status-id (db-getf row :last-status-id-fetched)) - (max-status-id-fetched (max-status-id-subscribed-tag tag))) + (max-status-id-fetched (max-status-id-subscribed-tag tag :include-ignored nil))) (or (null last-status-id) - (string> max-status-id-fetched - last-status-id))))) + (and max-status-id-fetched + (string> max-status-id-fetched + last-status-id)))))) (defun all-tags-with-new-message-fetched () "Returns the most recent messages fetched that contains subscribed tags, or @@ -2790,7 +2793,7 @@ nil if no such messages exist" (all-subscribed-tags-name))) (defun update-last-seen-status-with-tag (tag) - (when-let* ((max-status-id (max-status-id-subscribed-tag tag))) + (when-let* ((max-status-id (max-status-id-subscribed-tag tag :include-ignored nil))) (query (make-update +table-subscribed-tag+ (:last-status-id-fetched) (max-status-id) diff --git a/src/program-events.lisp b/src/program-events.lisp index b2914ee..120e205 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -977,7 +977,7 @@ (defmethod process-event ((object tag-mark-got-messages-event)) (loop for tag in (db:all-tags-with-new-message-fetched) do - (db:mark-tag-got-new-messages tag))) + (db:mark-tag-got-new-messages tag))) (defclass refresh-tag-window-event (program-event) ())