aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-04-18 18:33:21 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-04-18 18:53:51 +0200
commitf6a06454c793285e178265ab24552520198ea15a (patch)
tree517be7df3f4a629814b934d7d219e7992f2fef15 /lisp/mastodon-toot.el
parent98720451918cb33a345021ce0f1541acbb4c918b (diff)
test if any poll options go over the max, and re-run if so. FIX #436
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index e7cf22c..7404f18 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -828,6 +828,7 @@ instance to edit a toot."
(mastodon-http--triage
response
(lambda ()
+ (setq masto-poll-toot-response response)
(mastodon-toot--kill)
(if scheduled
(message "Toot scheduled!")
@@ -1234,8 +1235,18 @@ MAX is the maximum number set by their instance."
(defun mastodon-toot--read-poll-options (count length)
"Read a list of options for poll with COUNT options.
LENGTH is the maximum character length allowed for a poll option."
- (cl-loop for x from 1 to count
- collect (read-string (format "Poll option [%s/%s] [max %s chars]: " x count length))))
+ (let* ((choices
+ (cl-loop for x from 1 to count
+ collect (read-string
+ (format "Poll option [%s/%s] [max %s chars]: "
+ x count length))))
+ (longest (cl-reduce #'max (mapcar #'length choices))))
+ (if (> longest length)
+ (progn
+ (message "looks like you went over the max length. Try again.")
+ (sleep-for 2)
+ (mastodon-toot--read-poll-options count length))
+ choices)))
(defun mastodon-toot--read-poll-expiry ()
"Prompt for a poll expiry time."