diff options
author | mousebot <mousebot@riseup.net> | 2021-12-20 22:31:11 +0100 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-12-20 22:31:11 +0100 |
commit | 7d93e1f38332d03de0d935c7460bf3eb2821bf7d (patch) | |
tree | 16aa2f3996f10a6bac089eb702c7a3259043f36f /lisp | |
parent | 9620244cb4ece4e5503a3f5a6c73b948afa5ff74 (diff) |
docstring and move pin toot toggle
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-toot.el | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index f49b35c..ec1ba49 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -188,7 +188,8 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (propertize marker 'face 'success))))))) (defun mastodon-toot--action (action callback) - "Take ACTION on toot at point, then execute CALLBACK." + "Take ACTION on toot at point, then execute CALLBACK. +Makes a POST request to the server." (let* ((id (mastodon-tl--property 'base-toot-id)) (url (mastodon-http--api (concat "statuses/" (mastodon-tl--as-string id) @@ -248,26 +249,6 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (message (format "%s #%s" action id)))) (message "Nothing to favorite here?!?")))) -(defun mastodon-toot--pin-toot-toggle () - "Pin or unpin user's toot at point." - (interactive) - (let* ((toot (mastodon-tl--property 'toot-json)) - (pinnable-p (and - (not (alist-get 'reblog toot)) - (equal (alist-get 'acct - (alist-get 'account toot)) - (mastodon-auth--user-acct)))) - (pinned-p (equal (alist-get 'pinned toot) t)) - (action (if pinned-p "unpin" "pin")) - (msg (if pinned-p "unpinned" "pinned")) - (msg-y-or-n (if pinned-p "Unpin" "Pin"))) - (if (not pinnable-p) - (message "You can only pin your own toots.") - (if (y-or-n-p (format "%s this toot? " msg-y-or-n)) - (mastodon-toot--action action - (lambda () - (message "Toot %s!" msg))))))) - (defun mastodon-toot--copy-toot-url () "Copy URL of toot at point." (interactive) @@ -284,6 +265,22 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (equal (alist-get 'acct (alist-get 'account toot)) (mastodon-auth--user-acct)))) +(defun mastodon-toot--pin-toot-toggle () + "Pin or unpin user's toot at point." + (interactive) + (let* ((toot (mastodon-tl--property 'toot-json)) + (pinnable-p (mastodon-toot--own-toot-p toot)) + (pinned-p (equal (alist-get 'pinned toot) t)) + (action (if pinned-p "unpin" "pin")) + (msg (if pinned-p "unpinned" "pinned")) + (msg-y-or-n (if pinned-p "Unpin" "Pin"))) + (if (not pinnable-p) + (message "You can only pin your own toots.") + (if (y-or-n-p (format "%s this toot? " msg-y-or-n)) + (mastodon-toot--action action + (lambda () + (message "Toot %s!" msg))))))) + (defun mastodon-toot--delete-toot () "Delete user's toot at point synchronously." (interactive) |