aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-04 13:03:34 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-05 15:50:25 +0100
commitebbe5372bc4e1b99a97559982dbbe10ea7936c3b (patch)
treed823cd8ab25591a98fc6c61252f3d195c843e1bd /lisp/mastodon-tl.el
parentaf6cbd56602a4a1f56fd8bd9e6b8ac0d750bb0f5 (diff)
small improvements to poll display in timeline
revert display of poll votes
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el18
1 files changed, 15 insertions, 3 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 130b01f..3399791 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -946,6 +946,9 @@ this just means displaying toot client."
(defun mastodon-tl--get-poll (toot)
"If TOOT includes a poll, return it as a formatted string."
(let* ((poll (mastodon-tl--field 'poll toot))
+ (expiry (mastodon-tl--field 'expires_at poll))
+ (expired-p (if (eq (mastodon-tl--field 'expired poll) :json-false) nil t))
+ (multi (mastodon-tl--field 'multiple poll))
(options (mastodon-tl--field 'options poll))
(option-titles (mapcar (lambda (x)
(alist-get 'title x))
@@ -958,18 +961,27 @@ this just means displaying toot client."
(concat "\nPoll: \n\n"
(mapconcat (lambda (option)
(progn
- (format "Option %s: %s%s [%s votes].\n"
+ (format "%s: %s%s%s\n"
(setq option-counter (1+ option-counter))
- (alist-get 'title option)
+ (propertize (alist-get 'title option)
+ 'face 'success)
(make-string
(1+
(- (length longest-option)
(length (alist-get 'title
option))))
?\ )
- (alist-get 'votes_count option))))
+ ;; TODO: disambiguate no votes from hidden votes
+ (format "[%s votes]" (or (alist-get 'votes_count option)
+ "0")))))
options
"\n")
+ (unless expired-p
+ (propertize (format "Expires: %s" expiry)
+ 'face 'font-lock-comment-face))
+ (when expired-p
+ (propertize "Poll expired."
+ 'face 'font-lock-comment-face))
"\n")))
(defun mastodon-tl--poll-vote (option)