diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-05-23 22:23:53 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-05-23 22:23:53 +0200 |
commit | 34979f1a660f687795e10e2130bf05863181717b (patch) | |
tree | 7b9dfe8eab20d6060fb8aca761fbf63817cbce8f /lisp/mastodon-tl.el | |
parent | bc7be89d5297b5e2cd7b31a9281123578eb5c5bc (diff) |
tiny refactor tl--mute-or-unmute-thread
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r-- | lisp/mastodon-tl.el | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 90c2cbf..95a1456 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1753,29 +1753,25 @@ Note that you can only (un)mute threads you have posted in." (defun mastodon-tl--mute-or-unmute-thread (&optional unmute) "Mute a thread. If UNMUTE, unmute it." - (let ((endpoint (mastodon-tl--endpoint))) - (if (mastodon-tl--buffer-type-eq 'thread) - (let* ((id - (save-match-data - (string-match "statuses/\\(?2:[[:digit:]]+\\)/context" - endpoint) - (match-string 2 endpoint))) - (we-posted-p (mastodon-tl--user-in-thread-p id)) - (url (mastodon-http--api - (if unmute - (format "statuses/%s/unmute" id) - (format "statuses/%s/mute" id))))) - (if (not we-posted-p) - (message "You can only (un)mute a thread you have posted in.") - (when (if unmute - (y-or-n-p "Unnute this thread? ") - (y-or-n-p "Mute this thread? ")) - (let ((response (mastodon-http--post url))) - (mastodon-http--triage response - (lambda () - (if unmute - (message "Thread unmuted!") - (message "Thread muted!"))))))))))) + (let ((endpoint (mastodon-tl--endpoint)) + (mute-str (if unmute "unmute" "mute"))) + (when (mastodon-tl--buffer-type-eq 'thread) + (let* ((id + (save-match-data + (string-match "statuses/\\(?2:[[:digit:]]+\\)/context" + endpoint) + (match-string 2 endpoint))) + (we-posted-p (mastodon-tl--user-in-thread-p id)) + (url (mastodon-http--api (format "statuses/%s/%s" id mute-str)))) + (if (not we-posted-p) + (message "You can only (un)mute a thread you have posted in.") + (when (y-or-n-p (format "%s this thread? " (capitalize mute-str))) + (let ((response (mastodon-http--post url))) + (mastodon-http--triage response + (lambda () + (if unmute + (message "Thread unmuted!") + (message "Thread muted!"))))))))))) (defun mastodon-tl--map-account-id-from-toot (statuses) "Return a list of the account IDs of the author of each toot in STATUSES." |