aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-tl.el7
-rw-r--r--lisp/mastodon-toot.el23
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)))