diff --git a/src/thread-window.lisp b/src/thread-window.lisp index 71cac6b..a2bf232 100644 --- a/src/thread-window.lisp +++ b/src/thread-window.lisp @@ -1046,37 +1046,32 @@ db:renumber-timeline-message-index." :previous (_ "No previous message that contains ~s exists"))) -(defmethod search-next-unread ((object thread-window)) +(defun search-next-by-status (thread-window searching-function error-message) (with-accessors ((row-selected-index row-selected-index) (rows rows) (timeline-folder timeline-folder) - (timeline-type timeline-type)) object - (a:when-let* ((selected-fields (selected-row-fields object)) + (timeline-type timeline-type)) thread-window + (a:when-let* ((selected-fields (selected-row-fields thread-window)) (starting-index (db-utils:db-getf selected-fields :message-index))) - (let ((matching-status (db:search-next-unread-message timeline-type - timeline-folder - starting-index))) + (let ((matching-status (funcall searching-function + timeline-type + timeline-folder + starting-index))) (if matching-status (let ((new-message-index (db:row-message-index matching-status))) - (rebuild-lines object new-message-index) - (open-message object)) - (ui:info-message (_ "No others unread messages exist"))))))) + (rebuild-lines thread-window new-message-index) + (open-message thread-window)) + (ui:info-message error-message)))))) + +(defmethod search-next-unread ((object thread-window)) + (search-next-by-status object + #'db:search-next-unread-message + (_ "No others unread message exists"))) (defmethod search-next-undeleted ((object thread-window)) - (with-accessors ((row-selected-index row-selected-index) - (rows rows) - (timeline-folder timeline-folder) - (timeline-type timeline-type)) object - (a:when-let* ((selected-fields (selected-row-fields object)) - (starting-index (db-utils:db-getf selected-fields :message-index))) - (let ((matching-status (db:search-next-undeleted-message timeline-type - timeline-folder - starting-index))) - (if matching-status - (let ((new-message-index (db:row-message-index matching-status))) - (rebuild-lines object new-message-index) - (open-message object)) - (ui:info-message (_ "No others undeleted messages exist"))))))) + (search-next-by-status object + #'db:search-next-undeleted-message + (_ "No others message marked for deletion exists"))) (defmethod add-mention ((object thread-window) mention) (with-accessors ((mentions mentions)) object