aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-03-27 15:14:48 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-03-27 15:14:48 +0200
commitd1ffaca6e21b988255d1b980a9de6bb1d976e1af (patch)
tree9a483b73c45306a210d4f4fa1cc87eb443256a26 /lisp/mastodon-tl.el
parent34db55b8ae375bb397c1cb3614abaaa847d2de3f (diff)
work on reloading a view after sending an edited toot. FIX #421.
- fix up reload-timeline-or-profile - additions to --send for edited toots position of point is only rough, chosen from buffer point prior to reload, but buffers change on reload (things added if timeline, things removed if delete toot or clear notif. we may need to find a much better way.
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el47
1 files changed, 29 insertions, 18 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 3885220..c0c7e5e 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2075,25 +2075,36 @@ the current view."
(mastodon-http--get-json url args)))
;; TODO: add this to new posts in some cases, e.g. in thread view.
-(defun mastodon-tl--reload-timeline-or-profile ()
+(defun mastodon-tl--reload-timeline-or-profile (&optional pos)
"Reload the current timeline or profile page.
-For use after e.g. deleting a toot."
- (cond ((mastodon-tl--buffer-type-eq 'home)
- (mastodon-tl--get-home-timeline))
- ((mastodon-tl--buffer-type-eq 'federated)
- (mastodon-tl--get-federated-timeline))
- ((mastodon-tl--buffer-type-eq 'local)
- (mastodon-tl--get-local-timeline))
- ((mastodon-tl--buffer-type-eq 'notifications)
- (mastodon-notifications-get nil nil :force))
- ((mastodon-tl--buffer-type-eq 'own-profile)
- (mastodon-profile--my-profile))
- ((save-match-data
- (string-match
- "statuses/\\(?2:[[:digit:]]+\\)/context"
- (mastodon-tl--get-endpoint))
- (mastodon-tl--thread
- (match-string 2 (mastodon-tl--get-endpoint)))))))
+For use after e.g. deleting a toot.
+POS is a number, where point will be placed."
+ (let ((type (mastodon-tl--get-buffer-type)))
+ (cond ((eq type 'home)
+ (mastodon-tl--get-home-timeline))
+ ((eq type 'federated)
+ (mastodon-tl--get-federated-timeline))
+ ((eq type 'local)
+ (mastodon-tl--get-local-timeline))
+ ((eq type 'mentions)
+ (mastodon-notifications--get-mentions))
+ ((eq type 'notifications)
+ (mastodon-notifications-get nil nil :force))
+ ((eq type 'profile-statuses-no-boosts)
+ (mastodon-profile--open-statuses-no-reblogs))
+ ((eq type 'profile-statuses)
+ (mastodon-profile--my-profile))
+ ((eq type 'thread)
+ (save-match-data
+ (let ((endpoint (mastodon-tl--get-endpoint)))
+ (string-match
+ "statuses/\\(?2:[[:digit:]]+\\)/context"
+ endpoint)
+ (mastodon-tl--thread
+ (match-string 2 endpoint))))))
+ ;; TODO: sends point to POS, which was where point was in buffer before reload. This is very rough; we may have removed an item (deleted a toot, cleared a notif), so the buffer will be smaller, point will end up past where we were, etc.
+ (when pos
+ (goto-char pos))))
(defun mastodon-tl--build-link-header-url (str)
"Return a URL from STR, an http Link header."