diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-tl.el | 47 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 34 |
2 files changed, 48 insertions, 33 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." diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index dfc02ee..81185e8 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -773,11 +773,12 @@ instance to edit a toot." (let* ((toot (mastodon-toot--remove-docs)) (scheduled mastodon-toot--scheduled-for) (scheduled-id mastodon-toot--scheduled-id) + (edit-id mastodon-toot--edit-toot-id) (endpoint - (if mastodon-toot--edit-toot-id + (if edit-id ;; we are sending an edit: (mastodon-http--api (format "statuses/%s" - mastodon-toot--edit-toot-id)) + edit-id)) (mastodon-http--api "statuses"))) (spoiler (when (and (not (mastodon-toot--empty-p)) mastodon-toot--content-warning) @@ -819,22 +820,25 @@ instance to edit a toot." ((mastodon-toot--empty-p) (message "Empty toot. Cowardly refusing to post this.")) (t - (let ((response (if mastodon-toot--edit-toot-id + (let ((response (if edit-id ;; we are sending an edit: (mastodon-http--put endpoint args) (mastodon-http--post endpoint args)))) - (mastodon-http--triage response - (lambda () - (mastodon-toot--kill) - (if scheduled - (message "Toot scheduled!") - (message "Toot toot!")) - ;; cancel scheduled toot if we were editing it: - (when scheduled-id - (mastodon-views--cancel-scheduled-toot - scheduled-id :no-confirm)) - (mastodon-toot--restore-previous-window-config - prev-window-config)))))))) + (mastodon-http--triage + response + (lambda () + (mastodon-toot--kill) + (if scheduled + (message "Toot scheduled!") + (message "Toot toot!")) + ;; cancel scheduled toot if we were editing it: + (when scheduled-id + (mastodon-views--cancel-scheduled-toot + scheduled-id :no-confirm)) + (mastodon-toot--restore-previous-window-config prev-window-config) + (when edit-id + (let ((pos (marker-position (cadr prev-window-config)))) + (mastodon-tl--reload-timeline-or-profile pos)))))))))) ;; EDITING TOOTS: |