From f0822a697317e2e8bf320540e7ae1c80163bc90f Mon Sep 17 00:00:00 2001 From: mousebot Date: Thu, 23 Sep 2021 11:41:35 +0200 Subject: on delete toot, redraw current timeline or profile --- lisp/mastodon-tl.el | 15 +++++++++++++++ lisp/mastodon-toot.el | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d1e82d7..6304284 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1054,6 +1054,21 @@ webapp" (message "User %s (@%s) unblocked!" name user-handle))))) (message "Cannot find a user with handle %S" user-handle)))) +(defun mastodon-tl--reload-timeline-or-profile () + "Reload the current timeline or profile page. +For use after e.g. deleting a toot." + (cond ((equal (mastodon-tl--get-endpoint) "timelines/home") + (mastodon-tl--get-home-timeline)) + ((equal (mastodon-tl--get-endpoint) "timelines/public") + (mastodon-tl--get-federated-timeline)) + ((equal (mastodon-tl--get-endpoint) "timelines/public?local=true") + (mastodon-tl--get-local-timeline)) + ((equal (mastodon-tl--get-endpoint) "notifications") + (mastodon-notifications--get)) + ((equal (mastodon-tl--buffer-name) + (concat "*mastodon-" (mastodon-auth--get-account-name) "-statuses*")) + (mastodon-profile--my-profile)))) + (defun mastodon-tl--more () "Append older toots to timeline." (interactive) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index c9184fc..d86eefd 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -46,6 +46,7 @@ (autoload 'mastodon-toot "mastodon") (autoload 'mastodon-http--post-media-attachment "mastodon-http") (autoload 'mastodon-tl--toot-id "mastodon-tl") +(autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl") (defgroup mastodon-toot nil "Tooting in Mastodon." @@ -215,7 +216,6 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (kill-new url) (message "Toot URL copied to the clipboard."))) -;; TODO redraw buffer on success? (defun mastodon-toot--delete-toot () "Delete user's toot at point synchronously." (interactive) @@ -231,6 +231,7 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (let ((response (mastodon-http--delete url))) (mastodon-http--triage response (lambda () + (mastodon-tl--reload-timeline-or-profile) (message "Toot deleted!")))))))) (defun mastodon-toot--kill () -- cgit v1.2.3