branch: elpa/mastodon
commit 66b3aadc0753929acc81cb32643d05affb7d5419
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
group notifs: handle group data in json nil checks. FIX #642
---
lisp/mastodon-notifications.el | 6 +++++-
lisp/mastodon-tl.el | 19 ++++++++++++-------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 056ddc29d3..e21aad3033 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -89,7 +89,7 @@
(defvar mastodon-group-notifications)
(defvar mastodon-notifications-grouped-names-count)
(defvar mastodon-tl--link-keymap)
-
+(defvar mastodon-tl--update-point)
;;; VARIABLES
(defvar mastodon-notifications--map
@@ -612,6 +612,10 @@ Using GROUP data, notification TYPE, and overall notifs
JSON."
'id
(alist-get 'statuses json))))
+(defun mastodon-notifications--empty-group-json-p (json)
+ "Non-nil if JSON is empty grouped notifs data."
+ (equal json '((accounts) (statuses) (notification_groups))))
+
(defun mastodon-notifications--timeline (json &optional type update)
"Format JSON in Emacs buffer.
Optionally specify TYPE.
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 18115bbcc9..508332b098 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -94,7 +94,7 @@
(autoload 'mastodon-search-load-link-posts "mastodon-search")
(autoload 'mastodon-notifications--current-type "mastodon-notifications")
(autoload 'mastodon-notifications--timeline "mastodon-notifications")
-
+(autoload 'mastodon-notifications--empty-group-json-p "mastodon-notifications")
(defvar mastodon-toot--visibility)
(defvar mastodon-toot-mode)
(defvar mastodon-active-user)
@@ -3124,6 +3124,13 @@ report the account for spam."
;;; UPDATING, etc.
+(defun mastodon-tl--no-json (json)
+ "Nil if JSON is nil or empty group notif data."
+ (if (and (mastodon-tl--buffer-type-eq 'notifications)
+ mastodon-group-notifications)
+ (mastodon-notifications--empty-group-json-p json)
+ (not json)))
+
(defun mastodon-tl--more-json (endpoint id)
"Return JSON for timeline ENDPOINT before ID."
(let* ((args `(("max_id" . ,(mastodon-tl--as-string id))))
@@ -3174,7 +3181,8 @@ Then run CALLBACK with arguments CBARGS."
(defun mastodon-tl--updated-json (endpoint id &optional params version)
"Return JSON for timeline ENDPOINT since ID.
PARAMS is used to send any parameters needed to correctly update
-the current view."
+the current view.
+VERSION is the API version to use, as grouped notifs use v2."
(let* ((args `(("since_id" . ,(mastodon-tl--as-string id))))
(args (append args params))
(url (mastodon-http--api endpoint version)))
@@ -3319,7 +3327,7 @@ MAX-ID is the pagination parameter, a string."
(mastodon-tl--thread-do)
(goto-char point-before)
(message "Loaded full thread."))
- (if (not json)
+ (if (mastodon-tl--no-json json)
(user-error "No more results")
(if notifs-p
(mastodon-notifications--timeline json notif-type :update)
@@ -3528,10 +3536,7 @@ This location is defined by a non-nil value of
endpoint id params
(when (and notifs-p mastodon-group-notifications)
"v2"))))
- (if (not
- (if (and notifs-p mastodon-group-notifications)
- (alist-get 'statuses json)
- json))
+ (if (mastodon-tl--no-json json)
(user-error "Nothing to update")
(let ((inhibit-read-only t))
(mastodon-tl--set-after-update-marker)