1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2025-02-22 08:57:37 +01:00

- added mentions rendering in the thread window modeline.

This commit is contained in:
cage 2021-05-22 10:42:01 +02:00
parent 39e77c93cb
commit c2e8e38249
7 changed files with 58 additions and 8 deletions

View File

@ -22,7 +22,7 @@
# The text that starts the title section of a window # The text that starts the title section of a window
window.title.left.stopper.value = "╼▌" window.title.left.stopper.value = "╼▌"
# The text taht end the title section of a window # The text that end the title section of a window
window.title.right.stopper.value = "▐╾" window.title.right.stopper.value = "▐╾"
# default background color of terminal # default background color of terminal
@ -125,10 +125,15 @@ thread-window.modeline.background = blue
thread-window.modeline.foreground = yellow thread-window.modeline.foreground = yellow
# shown as a prefix for mentions in the modeline
thread-window.modeline.notification-icon.value = "📣"
# this variable customize the information that the modeline will # this variable customize the information that the modeline will
# shows, values prefixed with a '%' will be expanded, allowe values to # shows, values prefixed with a '%' will be expanded, allowe values to
# be expanded are: # be expanded are:
# - %m mentions count
# - %u user account # - %u user account
# - %s server connected to # - %s server connected to
# - %k current timeline # - %k current timeline
@ -138,7 +143,7 @@ thread-window.modeline.foreground = yellow
# - %tags in selected messages (if any) # - %tags in selected messages (if any)
# - %% a percent sign # - %% a percent sign
thread-window.modeline.value = "%u@%s ◈ %k %r/%t ◈ folder: %f ◈ tags: %h" thread-window.modeline.value = "%m %u@%s ◈ %k %r/%t ◈ folder: %f ◈ tags: %h"
# this is the only width you have to specify as the others windows # this is the only width you have to specify as the others windows
# just fills the void left by this one # just fills the void left by this one

View File

@ -640,7 +640,7 @@ numerical indices identifying the option voting for"
- max-id get notification until this id - max-id get notification until this id
- min-id starts getting notification newer than this id - min-id starts getting notification newer than this id
- since-id cut the notifications starting from this id - since-id cut the notifications starting from this id
- limit gets a maimum of messages up to this value - limit gets a maximum of messages up to this value
- exclude-types list types of modifications that will not be fetched." - exclude-types list types of modifications that will not be fetched."
(tooter:notifications *client* (tooter:notifications *client*
:max-id max-id :max-id max-id
@ -653,7 +653,7 @@ numerical indices identifying the option voting for"
(defun mentions (max-id &optional (excluded-types '(:follow :favourite :reblog))) (defun mentions (max-id &optional (excluded-types '(:follow :favourite :reblog)))
"Get the latest mentions, starting from `min-id` (pass nil to get "Get the latest mentions, starting from `min-id` (pass nil to get
the latest 15 mentions)." the latest 15 mentions)."
(get-notifications :max-id max-id (get-notifications :max-id max-id
:exclude-types excluded-types)) :exclude-types excluded-types))
(defun-api-call delete-notification (notification-id) (defun-api-call delete-notification (notification-id)

View File

@ -1706,7 +1706,7 @@ returns an alist of (local-username . acct)."
results)) results))
(defun mention-local->global-alist () (defun mention-local->global-alist ()
"Returns an alist of all known acoounts as ('@'local-username . '@'acct)." "Returns an alist of all known accounts as ('@'local-username . '@'acct)."
(let* ((query (select (:username :acct) (from +table-account+))) (let* ((query (select (:username :acct) (from +table-account+)))
(rows (fetch-all-rows query))) (rows (fetch-all-rows query)))
(loop for row in rows collect (loop for row in rows collect

View File

@ -1147,6 +1147,7 @@
:config-purge-history-days-offset :config-purge-history-days-offset
:config-purge-cage-days-offset :config-purge-cage-days-offset
:config-notification-life :config-notification-life
:config-notification-icon
:config-server-name :config-server-name
:config-username :config-username
:config-password-echo-character :config-password-echo-character
@ -1920,6 +1921,7 @@
:thread-window :thread-window
:timeline-type :timeline-type
:timeline-folder :timeline-folder
:mentions-count
:grow-tree-to-fit-window :grow-tree-to-fit-window
:fit-timeline-to-window :fit-timeline-to-window
:go-message-down :go-message-down
@ -1929,6 +1931,8 @@
:search-next-message-meta :search-next-message-meta
:search-previous-message-meta :search-previous-message-meta
:search-next-unread :search-next-unread
:increase-mentions-count
:decrease-mentions-count
:goto-message :goto-message
:goto-first-message :goto-first-message
:goto-last-message :goto-last-message

View File

@ -891,8 +891,10 @@
(defmethod process-event ((object update-mentions-event)) (defmethod process-event ((object update-mentions-event))
(when-let* ((mentions (api-client:update-mentions-folder :delete-mentions-on-server t)) (when-let* ((mentions (api-client:update-mentions-folder :delete-mentions-on-server t))
(mentions-count (length mentions))) (mentions-count (length mentions))
(thread-window specials:*thread-window*))
(when command-line:*notify-mentions* (when command-line:*notify-mentions*
(thread-window:increase-mentions-count thread-window mentions-count)
(ui:notify (format nil (ui:notify (format nil
(n_ "Got ~a notification" (n_ "Got ~a notification"
"Got ~a notifications" "Got ~a notifications"

View File

@ -436,6 +436,7 @@
input-dialog input-dialog
help-dialog help-dialog
notify-window notify-window
notification-icon
life life
quick-help quick-help
more-choices more-choices
@ -811,6 +812,12 @@
+key-notify-window+ +key-notify-window+
+key-life+) +key-life+)
(gen-simple-access (notification-icon)
+key-thread-window+
+key-modeline+
+key-notification-icon+
+key-value+)
(gen-simple-access (server-name) (gen-simple-access (server-name)
+key-server+) +key-server+)

View File

@ -112,7 +112,11 @@
(timeline-folder (timeline-folder
:initform db:+default-status-folder+ :initform db:+default-status-folder+
:initarg :timeline-folder :initarg :timeline-folder
:accessor timeline-folder))) :accessor timeline-folder)
(mentions-count
:initform 0
:initarg :mentions-count
:accessor mentions-count)))
(defmacro lambda-ignore-args (args &body body) (defmacro lambda-ignore-args (args &body body)
`(lambda (,@args) `(lambda (,@args)
@ -177,6 +181,16 @@
:account-id nil))) :account-id nil)))
""))) "")))
(defun expand-mentions (window)
(with-accessors ((mentions-count mentions-count)) window
(if (> mentions-count 0)
(with-tuify-results (window)
(format nil
"~a(~a)"
(swconf:config-notification-icon)
mentions-count))
"")))
(defun default-expander () (defun default-expander ()
(list (cons "%" (lambda (w) (with-tuify-results (w) "%"))) (list (cons "%" (lambda (w) (with-tuify-results (w) "%")))
(cons "s" (lambda (w) (with-tuify-results (w) (swconf:config-server-name)))) (cons "s" (lambda (w) (with-tuify-results (w) (swconf:config-server-name))))
@ -185,7 +199,8 @@
(cons "f" #'expand-folder-name) (cons "f" #'expand-folder-name)
(cons "h" #'expand-message-hashtags) (cons "h" #'expand-message-hashtags)
(cons "t" #'expand-total-messages) (cons "t" #'expand-total-messages)
(cons "r" #'expand-redp-messages))) (cons "r" #'expand-redp-messages)
(cons "m" #'expand-mentions)))
(defmethod initialize-instance :after ((object thread-window) &key &allow-other-keys) (defmethod initialize-instance :after ((object thread-window) &key &allow-other-keys)
(with-accessors ((mapping-code->fn mapping-code->fn)) object (with-accessors ((mapping-code->fn mapping-code->fn)) object
@ -303,6 +318,10 @@
(defgeneric search-previous-message-meta (object text-looking-for)) (defgeneric search-previous-message-meta (object text-looking-for))
(defgeneric increase-mentions-count (object &optional amount))
(defgeneric decrease-mentions-count (object &optional amount))
(defun message-root (tree) (defun message-root (tree)
(mtree:root-node tree)) (mtree:root-node tree))
@ -938,6 +957,19 @@ db:renumber-timeline-message-index."
(open-message object)) (open-message object))
(ui:info-message (_ "No others unread messages exist."))))))) (ui:info-message (_ "No others unread messages exist.")))))))
(defmethod increase-mentions-count ((object thread-window) &optional amount)
(with-accessors ((mentions-count mentions-count)) object
(let ((old-count mentions-count))
(incf mentions-count amount)
(setf mentions-count (max 0 mentions-count))
(values object old-count))))
(defmethod decrease-mentions-count ((object thread-window) &optional amount)
(multiple-value-bind (x old-count)
(increase-mentions-count object (- amount))
(declare (ignore x))
(values object old-count)))
(defgeneric marked-to-delete-p (object)) (defgeneric marked-to-delete-p (object))
(defmethod marked-to-delete-p ((object line)) (defmethod marked-to-delete-p ((object line))