[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mastodon a472f873a3 09/18: add widget to notifs view.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mastodon a472f873a3 09/18: add widget to notifs view. |
Date: |
Mon, 2 Dec 2024 16:00:34 -0500 (EST) |
branch: elpa/mastodon
commit a472f873a3ed499146f66eb54adf85ca73068b17
Author: marty hiatt <martianhiatus@disroot.org>
Commit: marty hiatt <martianhiatus@disroot.org>
add widget to notifs view.
---
lisp/mastodon-notifications.el | 27 +++++++++++++++++++--------
lisp/mastodon-tl.el | 5 +++--
lisp/mastodon-widget.el | 10 ++++++----
3 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 93a3d66204..c302db0e22 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -75,11 +75,12 @@
(defvar mastodon-profile-note-in-foll-reqs-max-length)
(defvar mastodon-group-notifications)
(defvar mastodon-notifications-grouped-names-count)
+
(defvar mastodon-notifications--types
- '("favourite" "reblog" "mention" "poll"
- "follow_request" "follow" "status" "update"
- "severed_relationships" "moderation_warning")
- "A list of notification types according to their name on the server.")
+ '("all" "favourite" "reblog" "mention" "poll"
+ "follow_request" "follow" "status" "update")
+ ;; "severed_relationships" "moderation_warning")
+ "A list of notification types according to their name on the server, plus
\"all\".")
(defvar mastodon-notifications--filter-types-alist
'(("all" . mastodon-notifications--get)
@@ -489,18 +490,28 @@ NO-GROUP means don't render grouped notifications."
;; `mastodon-tl--media-attachment', not here
(mastodon-media--inline-images start-pos (point)))))))
-(defun mastodon-notifications--timeline (json)
+(defun mastodon-notifications--timeline (json &optional type)
"Format JSON in Emacs buffer."
(if (seq-empty-p json)
(user-error "Looks like you have no (more) notifications for now")
+ (mastodon-widget--create
+ "Filter" mastodon-notifications--types
+ (or type "all")
+ (lambda (widget &rest _ignore)
+ (let ((value (widget-value widget)))
+ (mastodon-notifications--get-type value)))
+ :newline)
+ (insert "\n")
(mastodon-notifications--render json (not mastodon-group-notifications))
(goto-char (point-min))))
-(defun mastodon-notifications--get-type ()
+(defun mastodon-notifications--get-type (&optional type)
"Read a notification type and load its timeline."
(interactive)
- (let ((choice (completing-read "View notifications: "
- mastodon-notifications--filter-types-alist)))
+ (let ((choice (or type
+ (completing-read
+ "View notifications: "
+ mastodon-notifications--filter-types-alist))))
(funcall (alist-get
choice mastodon-notifications--filter-types-alist
nil nil #'equal))))
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 9f6ae5b828..9718684145 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -3399,10 +3399,10 @@ ENDPOINT-VERSION is a string, format Vx, e.g. V2."
link-header params nil
;; awful hack to fix multiple reloads:
(alist-get "max_id" params nil nil #'string=))
- (mastodon-tl--do-init json update-function)
+ (mastodon-tl--do-init json update-function nil nil note-type)
buffer)))
-(defun mastodon-tl--do-init (json update-fun &optional domain no-byline)
+(defun mastodon-tl--do-init (json update-fun &optional domain no-byline type)
"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.
@@ -3410,6 +3410,7 @@ NO-BYLINE means just insert toot body, used for
announcements."
(remove-overlays) ; video overlays
(cond (domain ;; maybe our update-fun doesn't always have 3 args...:
(funcall update-fun json nil domain))
+ (type (funcall update-fun json type)) ;; notif types
(no-byline (funcall update-fun json nil nil no-byline))
(t (funcall update-fun json)))
(setq
diff --git a/lisp/mastodon-widget.el b/lisp/mastodon-widget.el
index a5766722cb..e9376d8a2e 100644
--- a/lisp/mastodon-widget.el
+++ b/lisp/mastodon-widget.el
@@ -54,16 +54,18 @@ Note that such modes will need to require wid-edit.")
collect `(choice-item :value ,x :format "%[%v%] "
:keymap ,mastodon-widget-keymap)))
-(defun mastodon-widget--format (str &optional padding)
+(defun mastodon-widget--format (str &optional padding newline)
"Return a widget format string for STR, its name.
PADDING is an integer, for how much right-side padding to add."
(concat "%[" (propertize str
'face 'mastodon-widget-face
'mastodon-tab-stop t)
"%]: %v"
- (make-string padding ? )))
+ (make-string padding ? )
+ (if newline "\n" "")))
-(defun mastodon-widget--create (kind type value notify-fun)
+(defun mastodon-widget--create (kind type value notify-fun
+ &optional newline)
"Return a widget of KIND, with TYPE elements, and default VALUE.
KIND is a string, either Listing, Sort, Items, or Inbox, and will
be used for the widget's tag.
@@ -89,7 +91,7 @@ NOTIFY-FUN is the widget's notify function."
:value value
:args (mastodon-widget--return-item-widgets type-list)
:help-echo (format "Select a %s kind" kind)
- :format (mastodon-widget--format kind padding)
+ :format (mastodon-widget--format kind padding newline)
:notify notify-fun
;; eg format of notify-fun:
;; (lambda (widget &rest ignore)
- [nongnu] elpa/mastodon updated (cf64163130 -> 10be1f9c28), ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 2cfaf7458c 01/18: prefix for profile cycle completing-read. FIX #624., ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 7b98a4ca2a 02/18: notifs: typo in fun name prefix, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 7bc28cc75f 12/18: add prefix and view check to notif cycle, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 12d174dfd3 06/18: thread-do on reload after reply and bookmark load. FIX #625, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon a472f873a3 09/18: add widget to notifs view.,
ELPA Syncer <=
- [nongnu] elpa/mastodon 1545f3b78e 05/18: get-toot-author: never get booster profile. #630., ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon e9f77777dd 11/18: add cycle notif function. FIX #628., ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 10be1f9c28 18/18: Merge branch 'develop', ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 95d06a03eb 15/18: flycheck notifs.el, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 241d26dc1f 10/18: notif types: use types[] not exclude_types[], ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon be4a64a4ff 13/18: index, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon ba7e98c29c 17/18: bump, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 08307fee1b 14/18: notifs: require mastodon-widget, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon c08a84f82b 16/18: notifs cycle: buff type mentions or notifs, ELPA Syncer, 2024/12/02
- [nongnu] elpa/mastodon 00b1ac63d5 04/18: notifications--render: fallback to first id if no status_id. ??, ELPA Syncer, 2024/12/02