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

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

[nongnu] elpa/mastodon b078849b53 11/52: implement link-header paginatio


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon b078849b53 11/52: implement link-header pagination for foll-reqs
Date: Mon, 30 Oct 2023 16:01:24 -0400 (EDT)

branch: elpa/mastodon
commit b078849b534ddaaebdaf45ebee89d2fe59f3f696
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>

    implement link-header pagination for foll-reqs
---
 lisp/mastodon-tl.el    | 18 +++++++++++-------
 lisp/mastodon-views.el |  3 ++-
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 02c2dd7034..d5d127db52 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2340,12 +2340,13 @@ POS is a number, where point will be placed."
 
 (defun mastodon-tl--use-link-header-p ()
   "Return t if we are in a view needing Link header pagination.
-Currently this includes favourites, bookmarks, and profile pages
-when showing followers or accounts followed."
+Currently this includes favourites, bookmarks, follow requests,
+and profile pages when showing followers or accounts followed."
   (or (mastodon-tl--buffer-type-eq 'favourites)
       (mastodon-tl--buffer-type-eq 'bookmarks)
       (mastodon-tl--buffer-type-eq 'profile-followers)
-      (mastodon-tl--buffer-type-eq 'profile-following)))
+      (mastodon-tl--buffer-type-eq 'profile-following)
+      (mastodon-tl--buffer-type-eq 'follow-requests)))
 
 (defun mastodon-tl--get-link-header-from-response (headers)
   "Get http Link header from list of http HEADERS."
@@ -2363,7 +2364,7 @@ when showing followers or accounts followed."
       ;; "prev" type!
       (let ((link-header (mastodon-tl--link-header)))
         (if (> 2 (length link-header))
-            (error "No next page")
+            (message "No next page")
           (let* ((next (car link-header))
                  ;;(prev (cadr (mastodon-tl--link-header)))
                  (url (mastodon-tl--build-link-header-url next)))
@@ -2656,7 +2657,7 @@ JSON and http headers, without it just the JSON."
           (mastodon-tl--do-init json update-function))))))
 
 (defun mastodon-tl--init-sync (buffer-name endpoint update-function
-                                           &optional note-type params)
+                                           &optional note-type params headers)
   "Initialize BUFFER-NAME with timeline targeted by ENDPOINT.
 UPDATE-FUNCTION is used to receive more toots.
 Runs synchronously.
@@ -2670,9 +2671,12 @@ Optional arg NOTE-TYPE means only get that type of note."
          (params (append notes-params params))
          (url (mastodon-http--api endpoint))
          (buffer (concat "*mastodon-" buffer-name "*"))
-         (json (mastodon-http--get-json url params)))
+         (response (mastodon-http--get-response url params))
+         (json (if headers (car response) response))
+         (headers (if headers (cdr response) nil))
+         (link-header (mastodon-tl--get-link-header-from-response headers)))
     (with-mastodon-buffer buffer #'mastodon-mode nil
-      (mastodon-tl--set-buffer-spec buffer endpoint update-function nil params)
+      (mastodon-tl--set-buffer-spec buffer endpoint update-function 
link-header params)
       (mastodon-tl--do-init json update-function)
       buffer)))
 
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index dd46b59241..20734ae413 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -461,7 +461,8 @@ JSON is the data returned by the server."
                           "follow_requests"
                           'mastodon-views--insert-follow-requests
                           nil
-                          '(("limit" . "80"))) ; server max
+                          '(("limit" . "40")) ; server max is 80
+                          :headers)
   (mastodon-tl--goto-first-item)
   (with-current-buffer "*mastodon-follow-requests*"
     (use-local-map mastodon-views--view-follow-requests-keymap)))



reply via email to

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