aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2022-02-15 16:21:00 +0100
committermousebot <mousebot@riseup.net>2022-02-15 16:21:00 +0100
commitb26b4f835aee9317c13e98922342994e26a54078 (patch)
treebff0af7b2e13f7c5df4998fd2b9ffa4cb929ecaa /lisp
parent54e6ebf391bd6e7fee95f54802f63e06e4da7a2e (diff)
more robust goto-first-toot on timeline/thread load
rather than using goto-next-toot, which loops when we have no items in buffer
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-tl.el22
1 files changed, 16 insertions, 6 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index c059de8..deaa196 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -290,6 +290,15 @@ Optionally start from POS."
(mastodon-tl--goto-toot-pos 'next-single-property-change
'mastodon-tl--more))
+(defun mastodon-tl--goto-first-toot ()
+ "Jump to first toot or item in buffer.
+Used on initializing a timeline or thread."
+ ;; goto-next-toot assumes we already have toots, and is therefore
+ ;; incompatible with any view where it is possible to have no items.
+ ;; when that is the case the call to goto-toot-pos loops infinitely
+ (mastodon-tl--goto-toot-pos 'next-single-property-change
+ 'next-line)) ;dummy function as we need to feed it something
+
(defun mastodon-tl--goto-prev-toot ()
"Jump to last toot header."
(interactive)
@@ -1604,7 +1613,7 @@ JSON is the data returned from the server."
(when (or (equal endpoint "notifications")
(string-prefix-p "timelines" endpoint)
(string-prefix-p "statuses" endpoint))
- (mastodon-tl--goto-next-toot))))
+ (mastodon-tl--goto-first-toot))))
(defun mastodon-tl--init-sync (buffer-name endpoint update-function)
"Initialize BUFFER-NAME with timeline targeted by ENDPOINT.
@@ -1637,11 +1646,12 @@ Runs synchronously."
#'mastodon-tl--update-timestamps-callback
(current-buffer)
nil)))
- (when (or (equal endpoint "notifications")
- (string-prefix-p "timelines" endpoint)
- (string-prefix-p "statuses" endpoint))
- (mastodon-tl--goto-next-toot)))
- buffer))
+ (when (and (not (equal json '[]))
+ (or (equal endpoint "notifications")
+ (string-prefix-p "timelines" endpoint)
+ (string-prefix-p "statuses" endpoint))
+ (mastodon-tl--goto-first-toot))))
+ buffer))
(provide 'mastodon-tl)
;;; mastodon-tl.el ends here