diff options
author | marty hiatt <martianhiatus@disroot.org> | 2024-10-30 08:52:46 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus@disroot.org> | 2024-10-30 09:28:14 +0100 |
commit | 89f93a1316b229313dac36125a6ad439ed1e1ae1 (patch) | |
tree | 3d035eeba80b87cfa95ec3ae7e3d2316f88ddf03 /lisp | |
parent | 7d61f38a6bbe8a329892c5e91d1627a3ab03ee66 (diff) |
remove ACCOUNT and TYPE from our byline functions.
to avoid them, for foll/reqs we send the full notif as TOOT arg, and fetch
type/account from it as needed. muuuuuuuuch simpler, fingers crossed.
fix grouped notifs new non-account arg byline code
fix handle byline for grouped notifs
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-notifications.el | 18 | ||||
-rw-r--r-- | lisp/mastodon-tl.el | 41 |
2 files changed, 25 insertions, 34 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 6d6b339..1b04699 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -238,7 +238,7 @@ JSON is a list of alists." (mastodon-notifications--insert-note ;; toot (if (member type '(follow follow_request)) - follower + note ;; full notif, not just follower acct? status) ;; body (mastodon-notifiations--body-arg @@ -281,8 +281,7 @@ JSON is a list of alists." ;; action authors (cond ((member type '(follow follow_request mention)) "") ;; mentions are normal statuses - (t (mastodon-tl--byline-username - note (alist-get 'account note)))) + (t (mastodon-tl--byline-username note))) ;; action symbol: (unless (eq type 'mention) (mastodon-tl--symbol type)) @@ -395,7 +394,8 @@ JSON of the toot responded to. UNFOLDED is a boolean meaning whether to unfold or fold item if foldable. GROUP is the notification group data. -ACCOUNTS is the notification accounts data." +ACCOUNTS is the notification accounts data. +TYPE is notification type, used for non-group notifs." (let* ((type (if type (symbol-name type) ;; non-group (alist-get 'type group))) @@ -417,16 +417,10 @@ ACCOUNTS is the notification accounts data." ;; actual byline: (mastodon-tl--byline toot nil nil base-toot group - ;; FIXME: remove account arg (esp. if we have type). maybe we need - ;; type arg when we step from notifs (here); to tl--byline land - ;; (there): - (when (member type '("follow" "follow_request")) - toot) ;; account data! ;; types listed here use base item timestamp, else we use group's ;; latest timestamp: (when (not (member type '("favourite" "reblog" "edit" "poll"))) - (mastodon-tl--field 'latest_page_notification_at group)) - type)) + (mastodon-tl--field 'latest_page_notification_at group)))) 'item-type 'toot ;; for nav, actions, etc. 'item-id (or (alist-get 'page_max_id group) ;; newest notif (alist-get 'id toot)) ; toot id @@ -478,7 +472,7 @@ When DOMAIN, force inclusion of user's domain in their handle." (mastodon-tl--image-trans-check)) (mastodon-media--get-avatar-rendering .avatar)) (let ((uname (mastodon-tl--display-or-uname account))) - (mastodon-tl--byline-handle toot nil account + (mastodon-tl--byline-handle toot nil uname 'mastodon-display-name-face)) ", "))) nil ", ") diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 61014ff..4846164 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -610,14 +610,12 @@ Do so if type of status at poins is not follow_request/follow." (string= type "follow")) ; no counts for these (message "%s" echo))))) -;; FIXME: now that this can also be used for non byline rendering, let's -;; remove the toot arg, and deal with attachments higher up (on real -;; author byline only) removing toot arg makes it easier to render notifs -;; that have no status (foll_reqs) -(defun mastodon-tl--byline-username (toot &optional account) +(defun mastodon-tl--byline-username (toot) "Format a byline username from account in TOOT. -ACCOUNT is optionally acccount data to use." - (let-alist (or account (alist-get 'account toot)) +TOOT may be account data, or toot data, in which case acount data +is extracted from it." + (let-alist (or (alist-get 'account toot) + toot) ;; grouped nofifs use account data directly (propertize (if (not (string-empty-p .display_name)) .display_name .username) @@ -635,7 +633,7 @@ ACCOUNT is optionally acccount data to use." (string-suffix-p "-following*" (buffer-name))) (mastodon-tl--format-byline-help-echo toot))))) -(defun mastodon-tl--byline-handle (toot &optional domain account string face) +(defun mastodon-tl--byline-handle (toot &optional domain string face) "Format a byline handle from account in TOOT. DOMAIN is optionally added to the handle. ACCOUNT is optionally acccount data to use. @@ -643,7 +641,8 @@ STRING is optionally the string to propertize. FACE is optionally the face to use. The last two args allow for display a username as a clickable handle." - (let-alist (or account (alist-get 'account toot)) + (let-alist (or (alist-get 'account toot) + toot) ;; grouped notifs (propertize (or string (concat "@" .acct (when domain @@ -653,19 +652,18 @@ handle." 'face (or face 'mastodon-handle-face) 'mouse-face 'highlight 'mastodon-tab-stop 'user-handle - 'account account 'shr-url .url 'keymap mastodon-tl--link-keymap 'mastodon-handle (concat "@" .acct) 'help-echo (concat "Browse user profile of @" .acct)))) -(defun mastodon-tl--byline-uname-+-handle (data &optional domain account) +(defun mastodon-tl--byline-uname-+-handle (data &optional domain) "Concatenate a byline username and handle. DATA is the (toot) data to use. DOMAIN is optionally a domain for the handle. ACCOUNT is optionally acccount data to use." - (concat (mastodon-tl--byline-username data account) - " (" (mastodon-tl--byline-handle data domain account) ")")) + (concat (mastodon-tl--byline-username data) + " (" (mastodon-tl--byline-handle data domain) ")")) (defun mastodon-tl--display-or-uname (account) "Return display name or username from ACCOUNT data." @@ -673,7 +671,7 @@ ACCOUNT is optionally acccount data to use." (alist-get 'display_name account) (alist-get 'username account))) -(defun mastodon-tl--byline-author (toot &optional avatar domain base account) +(defun mastodon-tl--byline-author (toot &optional avatar domain base) "Propertize author of TOOT. If TOOT contains a reblog, return author of reblogged item. With arg AVATAR, include the account's avatar image. @@ -684,7 +682,7 @@ ACCOUNT is optionally acccount data to use." (let* ((data (if base (mastodon-tl--toot-or-base toot) toot)) - (account (or account (alist-get 'account data))) + (account (alist-get 'account data)) (uname (mastodon-tl--display-or-uname account))) (concat ;; avatar insertion moved up to `mastodon-tl--byline' by default to @@ -701,11 +699,11 @@ ACCOUNT is optionally acccount data to use." " " ;; username as button: (mastodon-tl--byline-handle - data domain account + data domain ;; display uname not handle (for boosts): uname 'mastodon-display-name-face)) ;; normal combo author byline: - (mastodon-tl--byline-uname-+-handle data domain account))))) + (mastodon-tl--byline-uname-+-handle data domain))))) (defun mastodon-tl--format-byline-help-echo (toot) "Format a help-echo for byline of TOOT. @@ -797,7 +795,7 @@ LETTER is a string, F for favourited, B for boosted, or K for bookmarked." (image-transforms-p))) (defun mastodon-tl--byline (toot &optional detailed-p - domain base-toot group account ts type) + domain base-toot group ts) "Generate byline for TOOT. AUTHOR-BYLINE is a function for adding the author portion of the byline that takes one variable. @@ -811,7 +809,7 @@ BASE-TOOT is JSON for the base toot, if any. GROUP is the notification group if any. ACCOUNT is the notification account if any. TS is a timestamp from the server, if any." - (let* ((type (or type (alist-get 'type (or group toot)))) + (let* ((type (alist-get 'type (or group toot))) (created-time (or ts ;; mentions, statuses, folls/foll-reqs ;; bosts, faves, edits, polls in notifs view use base item @@ -828,8 +826,7 @@ TS is a timestamp from the server, if any." (visibility (mastodon-tl--field 'visibility toot)) (base-toot-maybe (or base-toot ;; show edits for notifs (mastodon-tl--toot-or-base toot))) ;; for boosts - (account (or account - (alist-get 'account base-toot-maybe))) + (account (alist-get 'account base-toot-maybe)) (avatar-url (alist-get 'avatar account)) (edited-time (alist-get 'edited_at base-toot-maybe)) (edited-parsed (when edited-time (date-to-time edited-time)))) @@ -861,7 +858,7 @@ TS is a timestamp from the server, if any." ;; NB: action-byline (boost) is now added in insert-status, so no ;; longer part of the byline. ;; (base) author byline: - (mastodon-tl--byline-author toot nil domain :base account) + (mastodon-tl--byline-author toot nil domain :base) ;; visibility: (cond ((string= visibility "direct") (propertize (concat " " (mastodon-tl--symbol 'direct)) |