From 3823bfa94c43d9d26190e5c25ebb159933b7cc2b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 18 Feb 2023 22:03:07 +0100 Subject: get-link-header: test for "link" header specifically this prevents breakage if a profile's follwers/following is hidden. --- 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 57d827b..87bac66 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2994,8 +2994,8 @@ This location is defined by a non-nil value of (defun mastodon-tl--get-link-header-from-response (headers) "Get http Link header from list of http HEADERS." - (when headers - ;; pleroma uses "link", so case-insensitive match required: + ;; pleroma uses "link", so case-insensitive match required: + (when (alist-get "Link" headers nil nil 'cl-equalp) (split-string (alist-get "Link" headers nil nil 'cl-equalp) ", "))) (defun mastodon-tl--init (buffer-name endpoint update-function -- cgit v1.2.3 From 03eb2c807c7a07718b2c811038477eff014032b7 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 18 Feb 2023 22:07:17 +0100 Subject: handle no "next" link header, roughly --- lisp/mastodon-tl.el | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 87bac66..4323c66 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2767,16 +2767,21 @@ when showing followers or accounts followed." (message "Loading older toots...") (if (mastodon-tl--use-link-header-p) ;; link-header: can't build a URL with --more-json-async, endpoint/id: - (let* ((next (car (mastodon-tl--link-header))) - ;;(prev (cadr (mastodon-tl--link-header))) - (url (mastodon-tl--build-link-header-url next))) - (mastodon-http--get-response-async url nil 'mastodon-tl--more* (current-buffer) - (point) :headers)) - (mastodon-tl--more-json-async - (mastodon-tl--get-endpoint) - (mastodon-tl--oldest-id) - (mastodon-tl--update-params) - 'mastodon-tl--more* (current-buffer) (point)))) + ;; ensure we have a "next" type here, otherwise the CAR will be the + ;; "prev type!" + (let (link-header (mastodon-tl--link-header)) + (if (> 2 (length link-header)) + (error "No next page") + (let* ((next (car link-header)) + ;;(prev (cadr (mastodon-tl--link-header))) + (url (mastodon-tl--build-link-header-url next))) + (mastodon-http--get-response-async url nil 'mastodon-tl--more* (current-buffer) + (point) :headers)) + (mastodon-tl--more-json-async + (mastodon-tl--get-endpoint) + (mastodon-tl--oldest-id) + (mastodon-tl--update-params) + 'mastodon-tl--more* (current-buffer) (point)))))) (defun mastodon-tl--more* (response buffer point-before &optional headers) "Append older toots to timeline, asynchronously. -- cgit v1.2.3 From 09d6011da215fced6b8f49f8cf12ee9226b58d8d Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 18 Feb 2023 22:35:27 +0100 Subject: refactor tl--get-link-header --- 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 4323c66..257a6f2 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -3000,8 +3000,8 @@ This location is defined by a non-nil value of (defun mastodon-tl--get-link-header-from-response (headers) "Get http Link header from list of http HEADERS." ;; pleroma uses "link", so case-insensitive match required: - (when (alist-get "Link" headers nil nil 'cl-equalp) - (split-string (alist-get "Link" headers nil nil 'cl-equalp) ", "))) + (when-let ((link-headers (alist-get "Link" headers nil nil 'cl-equalp))) + (split-string link-headers ", "))) (defun mastodon-tl--init (buffer-name endpoint update-function &optional headers params hide-replies) -- cgit v1.2.3