From 937d2faba51ac8ab9503e106e9d0c83f88b61d75 Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 27 Nov 2022 13:37:50 +0100 Subject: [PATCH] - added a configuration directive to leave or delete mentions from the server after fetching them. --- etc/shared.conf | 4 ++++ src/api-client.lisp | 2 -- src/package.lisp | 1 + src/program-events.lisp | 24 +++++++++++++----------- src/software-configuration.lisp | 11 ++++++++++- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/etc/shared.conf b/etc/shared.conf index 775a508..39e502a 100644 --- a/etc/shared.conf +++ b/etc/shared.conf @@ -45,6 +45,10 @@ post-allowed-language = ".*" # (default 'no', change to 'yes' if desired) start.update.gemlog = no +# delete mentions fetched from the server + +delete.fetched.mentions = yes + # directory to scan for gempub files, default the same as # $XDG_DATA_HOME (usually something like %HOME/.local/share/tinmop/"). diff --git a/src/api-client.lisp b/src/api-client.lisp index 1b84a95..a1f1fe7 100644 --- a/src/api-client.lisp +++ b/src/api-client.lisp @@ -756,7 +756,6 @@ the latest 15 mentions)." mentions-so-far)) (defun update-mentions-folder (&key (delete-mentions-on-server t)) - (declare (ignorable delete-mentions-on-server)) ; because of the render macro '#-debug-mode' (let ((trees '())) (when-let* ((all-mentions (all-mentions)) (statuses (loop for mention in all-mentions @@ -774,7 +773,6 @@ the latest 15 mentions)." :folder db:+mentions-status-folder+ :localp t :min-id nil))) - #-debug-mode (when delete-mentions-on-server (loop for mention in all-mentions do (delete-notification (tooter:id mention)))) diff --git a/src/package.lisp b/src/package.lisp index 6cff073..2c21813 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1252,6 +1252,7 @@ :tree-config-rendering-values :make-tree-colormap :left-arrow + :config-delete-fetched-mentions-p :config-gemini-fullscreen-toc-width :config-gemini-fullscreen-links-height :config-post-allowed-language diff --git a/src/program-events.lisp b/src/program-events.lisp index 6b6b0e5..19e0b7c 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -971,17 +971,19 @@ (defclass update-mentions-event (program-event) ()) (defmethod process-event ((object update-mentions-event)) - (when-let* ((mentions (api-client:update-mentions-folder :delete-mentions-on-server t)) - (mentions-count (length mentions)) - (thread-window specials:*thread-window*)) - (when command-line:*notify-mentions* - (loop for mention in mentions do - (thread-window:add-mention thread-window mention)) - (ui:notify (format nil - (n_ "Got ~a notification" - "Got ~a notifications" - mentions-count) - mentions-count))))) + (let ((delete-fetched-mentions-required (swconf:config-delete-fetched-mentions-p))) + (when-let* ((mentions (api-client:update-mentions-folder + :delete-mentions-on-server delete-fetched-mentions-required)) + (mentions-count (length mentions)) + (thread-window specials:*thread-window*)) + (when command-line:*notify-mentions* + (loop for mention in mentions do + (thread-window:add-mention thread-window mention)) + (ui:notify (format nil + (n_ "Got ~a notification" + "Got ~a notifications" + mentions-count) + mentions-count)))))) (defclass expand-thread-event (program-event event-with-timeline-and-folder) ((status-id diff --git a/src/software-configuration.lisp b/src/software-configuration.lisp index d084f88..4b79962 100644 --- a/src/software-configuration.lisp +++ b/src/software-configuration.lisp @@ -601,6 +601,8 @@ selected unselected deleted + fetched + delete input read unread @@ -622,7 +624,8 @@ ignore-user-boost-re post-allowed-language purge-history-days-offset - purge-cache-days-offset) + purge-cache-days-offset + mentions) (defun perform-missing-value-check (file) (handler-case @@ -983,6 +986,12 @@ (,transform-value-fn (access:accesses *software-configuration* ,@keys)))) +(gen-simple-access (delete-fetched-mentions-p + :transform-value-fn db-utils:db-not-nil-p) + +key-delete+ + +key-fetched+ + +key-mentions+) + (gen-simple-access (gemini-fullscreen-toc-width :transform-value-fn main-window:parse-subwin-w) +key-gemini+