From 1b60a9ca18927769f30f7133d712d7459e7dd8ab Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Mon, 30 Sep 2024 15:12:12 +0500 Subject: Use interactive code to select event window --- lisp/mastodon-tl.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4058abc..8c41414 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1054,7 +1054,7 @@ Used for hitting RET on a given link." (defun mastodon-tl--do-link-action (event) "Do the action of the link at point. Used for a mouse-click EVENT on a link." - (interactive "e") + (interactive "@e") (mastodon-tl--do-link-action-at-point (posn-point (event-end event)))) @@ -1443,7 +1443,7 @@ OPTIONS is an alist." (defun mastodon-tl--click-image-or-video (event) "Click to play video with `mpv.el'. EVENT is a mouse-click arg." - (interactive "e") + (interactive "@e") (mastodon-tl--view-full-image-or-play-video (posn-point (event-end event)))) -- cgit v1.2.3 From 3a20ca8eef71966ef7d4ecde4ffedef49e25343a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 26 Oct 2024 10:03:59 +0200 Subject: add announcements timeline. (adds no-byline args to tl init funs) buffer check for announcements --- lisp/mastodon-tl.el | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 1a4df7f..8be802e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -590,6 +590,12 @@ With a double PREFIX arg, limit results to your own instance." 'mastodon-tl--timeline nil params))) +(defun mastodon-tl--announcements () + "Display announcements from your instance." + (interactive) + (mastodon-tl--init "announcements" "announcements" + 'mastodon-tl--timeline nil nil nil nil :no-byline)) + ;;; BYLINES, etc. @@ -814,7 +820,7 @@ ACCOUNT is the notification account if any." ;; all other toots, inc. boosts/faves in timelines: ;; (mastodon-tl--field auto fetches from reblogs if needed): (mastodon-tl--field 'created_at toot)))) - (parsed-time (date-to-time created-time)) + (parsed-time (when created-time (date-to-time created-time))) (faved (eq t (mastodon-tl--field 'favourited toot))) (boosted (eq t (mastodon-tl--field 'reblogged toot))) (bookmarked (eq t (mastodon-tl--field 'bookmarked toot))) @@ -1791,7 +1797,7 @@ NO-BYLINE means just insert toot body, used for folding." #'mastodon-tl--byline-author #'mastodon-tl--byline-boost nil nil detailed-p thread domain unfolded no-byline)))) -(defun mastodon-tl--timeline (toots &optional thread domain) +(defun mastodon-tl--timeline (toots &optional thread domain no-byline) "Display each toot in TOOTS. This function removes replies if user required. THREAD means the status will be displayed in a thread view. @@ -1807,7 +1813,7 @@ When DOMAIN, force inclusion of user's domain in their handle." (cl-remove-if-not #'mastodon-tl--is-reply toots) toots)))) (mapc (lambda (toot) - (mastodon-tl--toot toot nil thread domain)) + (mastodon-tl--toot toot nil thread domain nil no-byline)) toots) ;; media: (when mastodon-tl--display-media-p @@ -2117,7 +2123,9 @@ call this function after it is set or use something else." ((string= "*masto-image*" (buffer-name)) 'mastodon-image) ((mastodon-tl--endpoint-str-= "timelines/link") - 'link-timeline)))) + 'link-timeline) + ((mastodon-tl--endpoint-str-= "announcements") + 'announcements)))) (defun mastodon-tl--buffer-type-eq (type) "Return t if current buffer type is equal to symbol TYPE." @@ -3246,7 +3254,7 @@ This location is defined by a non-nil value of (defun mastodon-tl--init (buffer-name endpoint update-function &optional headers params - hide-replies instance) + hide-replies instance no-byline) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT asynchronously. UPDATE-FUNCTION is used to recieve more toots. HEADERS means to also collect the response headers. Used for paginating @@ -3264,11 +3272,12 @@ a timeline from." #'mastodon-http--get-response-async #'mastodon-http--get-json-async) url params 'mastodon-tl--init* - buffer endpoint update-function headers params hide-replies instance))) + buffer endpoint update-function headers params hide-replies + instance no-byline))) (defun mastodon-tl--init* (response buffer endpoint update-function &optional headers - update-params hide-replies instance) + update-params hide-replies instance no-byline) "Initialize BUFFER with timeline targeted by ENDPOINT. UPDATE-FUNCTION is used to recieve more toots. RESPONSE is the data returned from the server by @@ -3299,7 +3308,7 @@ JSON and http headers, without it just the JSON." link-header update-params hide-replies ;; awful hack to fix multiple reloads: (alist-get "max_id" update-params nil nil #'string=)) - (mastodon-tl--do-init json update-function instance))))))) + (mastodon-tl--do-init json update-function instance no-byline))))))) (defun mastodon-tl--init-sync (buffer-name endpoint update-function &optional note-type params @@ -3342,14 +3351,15 @@ ENDPOINT-VERSION is a string, format Vx, e.g. V2." (mastodon-tl--do-init json update-function) buffer))) -(defun mastodon-tl--do-init (json update-fun &optional domain) +(defun mastodon-tl--do-init (json update-fun &optional domain no-byline) "Utility function for `mastodon-tl--init*' and `mastodon-tl--init-sync'. JSON is the data to call UPDATE-FUN on. When DOMAIN, force inclusion of user's domain in their handle." (remove-overlays) ; video overlays - (if domain ;; maybe our update-fun doesn't always have 3 args...: - (funcall update-fun json nil domain) - (funcall update-fun json)) + (cond (domain ;; maybe our update-fun doesn't always have 3 args...: + (funcall update-fun json nil domain)) + (no-byline (funcall update-fun json nil nil no-byline)) + (t (funcall update-fun json))) (setq ;; Initialize with a minimal interval; we re-scan at least once ;; every 5 minutes to catch any timestamps we may have missed -- cgit v1.2.3 From eb736070d77d549c97e10f2c3560bcba17ba7d45 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 29 Oct 2024 08:45:33 +0100 Subject: fix timestamp logic in notifs v2 (use base item when necessary) --- lisp/mastodon-notifications.el | 12 ++++++++---- lisp/mastodon-tl.el | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 3ef8869..06bbca7 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -346,10 +346,14 @@ ACCOUNTS is the notification accounts data." 'toot-body t) ;; includes newlines etc. for folding "\n" ;; actual byline: - (mastodon-tl--byline toot author-byline nil nil - base-toot group - (if (member type '("follow" "follow_request")) - toot))) ;; account data! + (mastodon-tl--byline + toot author-byline nil nil base-toot group + (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)))) 'item-type 'toot ;; for nav, actions, etc. 'item-id (or (alist-get 'page_max_id group) ;; newest notif (alist-get 'id toot)) ; toot id diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 5bd1ec1..5eb52e3 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -797,7 +797,7 @@ LETTER is a string, F for favourited, B for boosted, or K for bookmarked." (image-transforms-p))) (defun mastodon-tl--byline (toot author-byline &optional detailed-p - domain base-toot group account) + domain base-toot group account ts) "Generate byline for TOOT. AUTHOR-BYLINE is a function for adding the author portion of the byline that takes one variable. @@ -809,17 +809,18 @@ this just means displaying toot client. When DOMAIN, force inclusion of user's domain in their handle. BASE-TOOT is JSON for the base toot, if any. GROUP is the notification group if any. -ACCOUNT is the notification account if any." - (let* ((created-time - (if group - (mastodon-tl--field 'latest_page_notification_at group) - ;; bosts and faves in notifs view - ;; (makes timestamps be for the original toot not the boost/fave): - (or (mastodon-tl--field 'created_at - (mastodon-tl--field 'status toot)) - ;; all other toots, inc. boosts/faves in timelines: - ;; (mastodon-tl--field auto fetches from reblogs if needed): - (mastodon-tl--field 'created_at toot)))) +ACCOUNT is the notification account if any. +TS is a timestamp from the server, if any." + (let* ((type (alist-get 'type group)) + (created-time + (or ts ;; mentions, statuses, folls/foll-reqs + ;; bosts, faves, edits, polls in notifs view use base item + ;; timestamp: + (mastodon-tl--field 'created_at + (mastodon-tl--field 'status toot)) + ;; all other toots, inc. boosts/faves in timelines: + ;; (mastodon-tl--field auto fetches from reblogs if needed): + (mastodon-tl--field 'created_at toot))) (parsed-time (when created-time (date-to-time created-time))) (faved (eq t (mastodon-tl--field 'favourited toot))) (boosted (eq t (mastodon-tl--field 'reblogged toot))) -- cgit v1.2.3