diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-04-18 10:33:24 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-18 10:44:40 -0400 |
commit | 27d152d85d9e26dc3080dfabb155980b22405c3f (patch) | |
tree | 283c4a047287ac5fa7830bea6459aa301a282607 /lisp | |
parent | 35a896aaf700e68f92883e93ce4cc4c3d1196ae6 (diff) |
Show boosted state with (B) marker in byline
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-tl.el | 7 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 23 |
2 files changed, 24 insertions, 6 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index a76aa1a..7139761 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -107,9 +107,14 @@ (mastodon-tl--byline-author reblog))))) (defun mastodon-tl--byline (toot) - (let ((id (cdr (assoc 'id toot)))) + (let ((id (cdr (assoc 'id toot))) + (boosted (or (cdr (assoc 'reblogged toot)) + (cdr (assoc 'reblogged + (cdr (assoc 'reblog toot))))))) (propertize (concat (propertize "\n | " 'face 'default) + (when boosted + (format "(%s) " (propertize "B" 'face 'success))) (mastodon-tl--byline-author toot) (mastodon-tl--byline-boosted toot) (propertize "\n ------------" 'face 'default)) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index d677f5d..e567cc6 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -61,7 +61,23 @@ STATUS is passed by `url-retrieve'." (interactive) (kill-buffer-and-window)) -;; TODO extract success callback +(defun mastodon-toot--action-success (marker) + "Insert MARKER with 'success face in byline." + (let ((inhibit-read-only t)) + (mastodon-tl--property 'toot-id) + (goto-char (+ 3 (point))) + (insert (format "(%s) " + (propertize marker + 'face 'success))))) + +(defun mastodon-toot--boost-triage (response) + "Parse response code from RESPONSE buffer." + (let ((status (with-current-buffer response + (mastodon--response-code)))) + (if (string-prefix-p "2" status) + (mastodon-toot--action-success "B") + (switch-to-buffer response)))) + (defun mastodon-toot--boost () "Boost toot at point." (interactive) @@ -70,10 +86,7 @@ STATUS is passed by `url-retrieve'." (number-to-string id) "/reblog")))) (let ((response (mastodon-http--post url nil nil))) - (with-current-buffer response - (if (string-prefix-p "2" (mastodon--response-code)) - (message "Boosted!") - (switch-to-buffer response)))))) + (mastodon-toot--boost-triage response)))) (defvar mastodon-toot-mode-map (let ((map (make-sparse-keymap))) |