From 5f496643a1c04532337d97c23dc09c650c39d1b5 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Tue, 25 Apr 2017 23:45:29 -0400 Subject: Add toggle function for boost/unboost --- lisp/mastodon-toot.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 41b69cc..6345e14 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -62,11 +62,19 @@ Remove MARKER if RM is non-nil." (let ((response (mastodon-http--post url nil nil))) (mastodon-http--triage response callback)))) -(defun mastodon-toot--toggle-favourite () - "Favourite/unfavourite toot based on current state. +(defun mastodon-toot--toggle-boost () + "Boost/unboost toot at `point'." + (interactive) + (let* ((id (mastodon-tl--property 'toot-id)) + (boosted (get-text-property (point) 'boosted-p)) + (action (if boosted "unreblog" "reblog")) + (msg (if boosted "unboosted" "boosted")) + (remove (when boosted t))) + (mastodon-toot--action action (lambda () (mastodon-toot--action-success "B" remove))) + (message (format "%s #%s" msg id)))) -If FAVED is nil, favourite the toot. -If FAVED is non-nil, unfavourite the toot." +(defun mastodon-toot--toggle-favourite () + "Favourite/unfavourite toot at `point'." (interactive) (let* ((id (mastodon-tl--property 'toot-id)) (faved (get-text-property (point) 'favourited-p)) @@ -107,14 +115,6 @@ Set `mastodon-toot--content-warning' to nil." (mastodon-http--triage response (lambda () (message "Toot toot!"))))))) -(defun mastodon-toot--boost () - "Boost toot at `point'." - (interactive) - (let ((callback (lambda () (mastodon-toot--action-success "B"))) - (id (mastodon-tl--property 'toot-id))) - (mastodon-toot--action "reblog" callback) - (message (format "Boosted #%s" id)))) - (defun mastodon-toot--reply () "Reply to toot at `point'." (interactive) -- cgit v1.2.3