aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-18 13:55:16 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-18 15:03:01 -0400
commitb2f927617e0e6394cfe55bb603668ee689480103 (patch)
treeaa94f1ee03ef0d5e629b17dc7a82b3f90da576b8
parent6375aa46466b980d5923773f7fe04e11384d82f0 (diff)
Add and use mastodon-tl--field function
Retrieves FIELD from TOOT, prioritizing FIELD from boosted toot before TOOT itself.
-rw-r--r--lisp/mastodon-tl.el24
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 6358c72..e1487bd 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -106,14 +106,17 @@
" "
(mastodon-tl--byline-author reblog)))))
+(defun mastodon-tl--field (field toot)
+ "Return FIELD from TOOT.
+
+Return value from boosted content if available."
+ (or (cdr (assoc field (cdr (assoc 'reblog toot))))
+ (cdr (assoc field toot))))
+
(defun mastodon-tl--byline (toot)
(let ((id (cdr (assoc 'id toot)))
- (faved (or (cdr (assoc 'favourited toot))
- (cdr (assoc 'favourited
- (cdr (assoc 'reblog toot))))))
- (boosted (or (cdr (assoc 'reblogged toot))
- (cdr (assoc 'reblogged
- (cdr (assoc 'reblog toot)))))))
+ (faved (mastodon-tl--field 'favourited toot))
+ (boosted (mastodon-tl--field 'reblogged toot)))
(propertize
(concat (propertize "\n | " 'face 'default)
(when boosted
@@ -123,13 +126,12 @@
(mastodon-tl--byline-author toot)
(mastodon-tl--byline-boosted toot)
(propertize "\n ------------" 'face 'default))
- 'toot-id id)))
+ 'toot-id id
+ 'toot-json toot)))
(defun mastodon-tl--content (toot)
- (let* ((reblog (cdr (assoc 'reblog toot)))
- (content (if reblog
- (cdr (assoc 'content reblog))
- (cdr (assoc 'content toot)))))
+ "Retrieve text content from TOOT."
+ (let ((content (mastodon-tl--field 'content toot)))
(propertize (mastodon-tl--remove-html content)
'face 'default)))