[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mastodon 464d2e4634 20/50: notifs: factor an action-byline
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mastodon 464d2e4634 20/50: notifs: factor an action-byline fun (maybe move into insert-note) |
Date: |
Sat, 2 Nov 2024 13:00:53 -0400 (EDT) |
branch: elpa/mastodon
commit 464d2e463423f7c431f85497658531312c2ad448
Author: marty hiatt <martianhiatus@disroot.org>
Commit: marty hiatt <martianhiatus@disroot.org>
notifs: factor an action-byline fun (maybe move into insert-note)
---
lisp/mastodon-notifications.el | 153 +++++++++++++++++++++--------------------
1 file changed, 79 insertions(+), 74 deletions(-)
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 384241d7b8..e5ad1ea812 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -244,16 +244,8 @@ JSON is a list of alists."
(mastodon-notifiations--body-arg
type filters status profile-note follower-name)
;; action-byline (top)
- (unless (member type '(follow follow_request mention))
- (downcase
- (mastodon-notifications--byline-concat
- (alist-get type mastodon-notifications--action-alist))))
- ;; action authors
- (cond ((member type '(follow follow_request mention))
- "") ;; mentions are normal statuses
- (t (mastodon-tl--byline-handle note nil
- follower-name
- 'mastodon-display-name-face)))
+ (mastodon-notifications--action-byline
+ type nil nil note follower-name)
;; base toot (always provide)
status
nil nil nil type))))
@@ -288,20 +280,36 @@ ACCOUNTS is data of the accounts that have reacted to the
notification."
(mastodon-notifiations--body-arg
type filters status profile-note follower-name group)
;; action-byline
- (unless (member type '(follow follow_request mention))
- (downcase
- (mastodon-notifications--byline-concat
- (alist-get type mastodon-notifications--action-alist))))
- ;; action authors
- (cond ((member type '(follow follow_request mention))
- "") ;; mentions are normal statuses
- (t (mastodon-notifications--byline-accounts
- accounts status group)))
+ (mastodon-notifications--action-byline
+ type accounts group)
;; base toot (no need for update/poll/?)
(when (member type '(favourite reblog))
status)
folded group accounts))))))
+(defun mastodon-notifications--action-byline
+ (type &optional accounts group note follower-name)
+ "TYPE ACCOUNTS GROUP NOTE FOLLOWER-NAME."
+ (let ((action-str
+ (unless (member type '(follow follow_request mention))
+ (downcase
+ (mastodon-notifications--byline-concat
+ (alist-get type mastodon-notifications--action-alist)))))
+ (action-symbol (if (eq type 'mention)
+ ""
+ (mastodon-tl--symbol type)))
+ (action-authors
+ (if (member type '(follow follow_request mention))
+ "" ;; mentions are normal statuses
+ (if group
+ (mastodon-notifications--byline-accounts accounts group)
+ (mastodon-tl--byline-handle note nil
+ follower-name
+ 'mastodon-display-name-face)))))
+ (propertize
+ (concat action-symbol " " action-authors action-str)
+ 'byline-top t)))
+
(defun mastodon-notifiations--body-arg
(type &optional filters status profile-note follower-name group)
"TYPE is a symbol, a member of `mastodon-notifiations--types'.
@@ -338,9 +346,9 @@ FILTERS STATUS PROFILE-NOTE FOLLOWER-NAME GROUP."
(t body))))
(defun mastodon-notifications--insert-note
- (toot body action-byline action-authors
+ (toot body action-byline
&optional base-toot unfolded group accounts type)
- "Display the content and byline of timeline element TOOT.
+"Display the content and byline of timeline element TOOT.
BODY will form the section of the toot above the byline.
AUTHOR-BYLINE is an optional function for adding the author
portion of the byline that takes one variable. By default it is
@@ -360,59 +368,56 @@ foldable.
GROUP is the notification group 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)))
- (action-symbol (unless (eq type 'mention)
- (mastodon-tl--symbol (intern type))))
- (toot-foldable
- (and mastodon-tl--fold-toots-at-length
- (length> body mastodon-tl--fold-toots-at-length))))
- (insert
- (propertize ;; top byline, body + byline:
- (concat
- (if (equal type "mention")
- ""
- (propertize ;; top byline
- (concat action-symbol " " action-authors action-byline)
- 'byline-top t))
- (propertize body ;; body only
- 'toot-body t) ;; includes newlines etc. for folding
- "\n"
- ;; actual byline:
- (mastodon-tl--byline
- toot nil nil base-toot group
- ;; 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))))
- 'item-type 'toot ;; for nav, actions, etc.
- 'item-id (or (alist-get 'page_max_id group) ;; newest notif
- (alist-get 'id toot)) ; toot id
- 'base-item-id (mastodon-tl--item-id
- ;; if status is a notif, get id from base-toot
- ;; (-tl--item-id toot) will not work here:
- (or base-toot
- toot)) ; else normal toot with reblog check
- 'item-json toot
- 'base-toot base-toot
- 'cursor-face 'mastodon-cursor-highlight-face
- 'toot-foldable toot-foldable
- 'toot-folded (and toot-foldable (not unfolded))
- ;; grouped notifs data:
- 'notification-type type
- 'notification-id (alist-get 'group_key group)
- 'notification-group group
- 'notification-accounts accounts
- ;; for pagination:
- 'notifications-min-id (alist-get 'page_min_id group)
- 'notifications-max-id (alist-get 'page_max_id group))
- "\n")))
-
-;; FIXME: REFACTOR with -tl--byline?:
-;; we provide account directly, rather than let-alisting toot
-;; almost everything is .account.field anyway
-;; but toot still needed also, for attachments, etc.
+(let* ((type (if type
+ (symbol-name type) ;; non-group
+ (alist-get 'type group)))
+ (toot-foldable
+ (and mastodon-tl--fold-toots-at-length
+ (length> body mastodon-tl--fold-toots-at-length)))
+ (follower (alist-get 'account toot))
+ (follower-name (or (alist-get 'display_name follower)
+ (alist-get 'username follower))))
+ (insert
+ (propertize ;; top byline, body + byline:
+ (concat
+ (if (equal type "mention") ;; top (action) byline
+ ""
+ action-byline)
+ ;; (mastodon-notifications--action-byline
+ ;; (intern type) accounts group toot follower-name))
+ (propertize body ;; body only
+ 'toot-body t) ;; includes newlines etc. for folding
+ "\n"
+ ;; actual byline:
+ (mastodon-tl--byline
+ toot nil nil base-toot group
+ ;; 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))))
+ 'item-type 'toot ;; for nav, actions, etc.
+ 'item-id (or (alist-get 'page_max_id group) ;; newest notif
+ (alist-get 'id toot)) ; toot id
+ 'base-item-id (mastodon-tl--item-id
+ ;; if status is a notif, get id from base-toot
+ ;; (-tl--item-id toot) will not work here:
+ (or base-toot
+ toot)) ; else normal toot with reblog check
+ 'item-json toot
+ 'base-toot base-toot
+ 'cursor-face 'mastodon-cursor-highlight-face
+ 'toot-foldable toot-foldable
+ 'toot-folded (and toot-foldable (not unfolded))
+ ;; grouped notifs data:
+ 'notification-type type
+ 'notification-id (alist-get 'group_key group)
+ 'notification-group group
+ 'notification-accounts accounts
+ ;; for pagination:
+ 'notifications-min-id (alist-get 'page_min_id group)
+ 'notifications-max-id (alist-get 'page_max_id group))
+ "\n")))
+
(defun mastodon-notifications--byline-accounts
(accounts group &optional avatar)
"Propertize author byline ACCOUNTS.
- [nongnu] elpa/mastodon updated (c241b0ba9d -> 31557be472), ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 7d61f38a6b 07/50: FIX #609. insert-status remove author-byline arg, its always the same function, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 198c7ae8c7 24/50: bump tp version, bump version, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 16779f5820 39/50: readme for some of the new stuff, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 6f9cb5c18f 36/50: add mention symbol, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 464d2e4634 20/50: notifs: factor an action-byline fun (maybe move into insert-note),
ELPA Syncer <=
- [nongnu] elpa/mastodon 89f93a1316 08/50: remove ACCOUNT and TYPE from our byline functions., ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon db0e6bdf54 12/50: Merge branch 'develop' into non-group-notifs, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 2b281fcc49 13/50: byte-compile, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 411e9f22e0 14/50: grouped notifs: top byline create with account data, not toot. #612 half fixed., ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 380c6be86f 22/50: keep cleaning up notifs insert note, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon c7a3ed75ab 26/50: fold-toot - respect CW state, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 8a8b13dc0a 21/50: --byline: pull fave/boost/edit/visibility from base toot if present, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 1bf73f2528 33/50: remove elsa from Cask, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon ee25cb9b02 41/50: update point after widget. FIX #615, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon c09935b100 37/50: tl: remove stale args to insert status, inc. action-byline arg, ELPA Syncer, 2024/11/02