emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mastodon e400757d24 03/18: view notifs by type, w completi


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon e400757d24 03/18: view notifs by type, w completing-read. #628.
Date: Mon, 2 Dec 2024 16:00:33 -0500 (EST)

branch: elpa/mastodon
commit e400757d245f516d356b3d875f0b120c232d2c65
Author: marty hiatt <martianhiatus@disroot.org>
Commit: marty hiatt <martianhiatus@disroot.org>

    view notifs by type, w completing-read. #628.
---
 lisp/mastodon-notifications.el | 69 ++++++++++++++++++++++++++++++++----------
 1 file changed, 53 insertions(+), 16 deletions(-)

diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 1fafa3bf69..804cc7d2a1 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -81,15 +81,28 @@
     "severed_relationships" "moderation_warning")
   "A list of notification types according to their name on the server.")
 
+(defvar mastodon-notifications--filter-types-alist
+  '(("all"                    . mastodon-notifications--get)
+    ("favourite"              . mastodon-notifications--get-favourites)
+    ("reblog"                 . mastodon-notifications--get-boosts)
+    ("mention"                . mastodon-notifications--get-mentions)
+    ("poll"                   . mastodon-notifications--get-polls)
+    ("follow_request"         . mastodon-notifications--get-follow-requests)
+    ("follow"                 . mastodon-notifications--get-follows)
+    ("status"                 . mastodon-notifications--get-statuses)
+    ("update"                 . mastodon-notifications--get-edits))
+  "An alist of notification types and their corresponding load functions.
+Notification types are named according to their name on the server.")
+
 (defvar mastodon-notifications--response-alist
-  '(("Followed" . "you")
-    ("Favourited" . "your post")
-    ("Boosted" . "your post")
-    ("Mentioned" . "you")
-    ("Posted a poll" . "that has now ended")
-    ("Requested to follow" . "you")
-    ("Posted" . "a post")
-    ("Edited" . "their post"))
+  '(("Followed"             . "you")
+    ("Favourited"           . "your post")
+    ("Boosted"              . "your post")
+    ("Mentioned"            . "you")
+    ("Posted a poll"        . "that has now ended")
+    ("Requested to follow"  . "you")
+    ("Posted"               . "a post")
+    ("Edited"               . "their post"))
   "Alist of subjects for notification types.")
 
 (defvar mastodon-notifications--map
@@ -171,14 +184,14 @@ Can be called in notifications view or in follow-requests 
view."
   "List of notification types for which grouping is implemented.")
 
 (defvar mastodon-notifications--action-alist
-  '((reblog . "Boosted")
-    (favourite . "Favourited")
-    (follow_request . "Requested to follow")
-    (follow . "Followed")
-    (mention . "Mentioned")
-    (status . "Posted")
-    (poll . "Posted a poll")
-    (update . "Edited"))
+  '((reblog          . "Boosted")
+    (favourite       . "Favourited")
+    (follow_request  . "Requested to follow")
+    (follow          . "Followed")
+    (mention         . "Mentioned")
+    (status          . "Posted")
+    (poll            . "Posted a poll")
+    (update          . "Edited"))
   "Action strings keyed by notification type.
 Types are those of the Mastodon API.")
 
@@ -478,6 +491,15 @@ NO-GROUP means don't render grouped notifications."
     (mastodon-notifications--render json (not mastodon-group-notifications))
     (goto-char (point-min))))
 
+(defun mastodon-notifications--get-type ()
+  "Read a notification type and load its timeline."
+  (interactive)
+  (let ((choice (completing-read "View notifications: "
+                                 mastodon-notifications--filter-types-alist)))
+    (funcall (alist-get
+              choice mastodon-notifications--filter-types-alist
+              nil nil #'equal))))
+
 (defun mastodon-notifications--get-mentions ()
   "Display mention notifications in buffer."
   (interactive)
@@ -505,6 +527,21 @@ Status notifications are created when you call
   (interactive)
   (mastodon-notifications-get "status" "statuses"))
 
+(defun mastodon-notifications--get-follows ()
+  "Display follow notifications in buffer."
+  (interactive)
+  (mastodon-notifications-get "follow" "follows"))
+
+(defun mastodon-notifications--get-follow-requests ()
+  "Display follow request notifications in buffer."
+  (interactive)
+  (mastodon-notifications-get "follow_request" "follow-requests"))
+
+(defun mastodon-notifications--get-edits ()
+  "Display edited post notifications in buffer."
+  (interactive)
+  (mastodon-notifications-get "update" "edits"))
+
 (defun mastodon-notifications--filter-types-list (type)
   "Return a list of notification types with TYPE removed."
   (remove type mastodon-notifications--types))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]