aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-03-16 20:03:48 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-03-16 20:03:48 +0100
commita34056094d1ced2c492a58c4c27fe658133d1bfe (patch)
treee8ee67f2694844b85a4fa7e160f5018fabef0f7e /lisp
parentc088137b1cbe5c4d0b9d5f732a2bd5b894531fe3 (diff)
disallow -toot--set-visibility / --schedule-toot in edit-toot
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-toot.el80
1 files changed, 42 insertions, 38 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 7c67c49..b9e97b6 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -1059,16 +1059,18 @@ text of the toot being replied to in the compose buffer."
(defun mastodon-toot--change-visibility ()
"Change the current visibility to the next valid value."
(interactive)
- (setq mastodon-toot--visibility
- (cond ((string= mastodon-toot--visibility "public")
- "unlisted")
- ((string= mastodon-toot--visibility "unlisted")
- "private")
- ((string= mastodon-toot--visibility "private")
- "direct")
- (t
- "public")))
- (mastodon-toot--update-status-fields))
+ (if (mastodon-tl--buffer-type-eq 'edit-toot)
+ (message "You can't change visibility when editing toots.")
+ (setq mastodon-toot--visibility
+ (cond ((string= mastodon-toot--visibility "public")
+ "unlisted")
+ ((string= mastodon-toot--visibility "unlisted")
+ "private")
+ ((string= mastodon-toot--visibility "private")
+ "direct")
+ (t
+ "public")))
+ (mastodon-toot--update-status-fields)))
(defun mastodon-toot--clear-all-attachments ()
"Remove all attachments from a toot draft."
@@ -1230,34 +1232,36 @@ With RESCHEDULE, reschedule the scheduled toot at point without editing."
;; original idea by christian tietze, thanks!
;; https://codeberg.org/martianh/mastodon.el/issues/285
(interactive)
- (let* ((id (when reschedule (get-text-property (point) 'id)))
- (ts (when reschedule
- (alist-get 'scheduled_at
- (get-text-property (point) 'scheduled-json))))
- (time-value
- (org-read-date t t nil "Schedule toot:"
- ;; default to scheduled timestamp if already set:
- (mastodon-toot--iso-to-org
- ;; we are rescheduling without editing:
- (or ts
- ;; we are maybe editing the scheduled toot:
- mastodon-toot--scheduled-for))))
- (iso8601-str (format-time-string "%FT%T%z" time-value))
- (msg-str (format-time-string "%d-%m-%y at %H:%M[%z]" time-value)))
- (if (not reschedule)
- (progn
- (setq-local mastodon-toot--scheduled-for iso8601-str)
- (message (format "Toot scheduled for %s." msg-str)))
- (let* ((args (when reschedule `(("scheduled_at" . ,iso8601-str))))
- (url (when reschedule (mastodon-http--api
- (format "scheduled_statuses/%s" id))))
- (response (mastodon-http--put url args)))
- (mastodon-http--triage response
- (lambda ()
- ;; reschedule means we are in scheduled toots view:
- (mastodon-tl--view-scheduled-toots)
- (message
- (format "Toot rescheduled for %s." msg-str))))))))
+ (if (mastodon-tl--buffer-type-eq 'edit-toot)
+ (message "You can't schedule toots you're editing.")
+ (let* ((id (when reschedule (get-text-property (point) 'id)))
+ (ts (when reschedule
+ (alist-get 'scheduled_at
+ (get-text-property (point) 'scheduled-json))))
+ (time-value
+ (org-read-date t t nil "Schedule toot:"
+ ;; default to scheduled timestamp if already set:
+ (mastodon-toot--iso-to-org
+ ;; we are rescheduling without editing:
+ (or ts
+ ;; we are maybe editing the scheduled toot:
+ mastodon-toot--scheduled-for))))
+ (iso8601-str (format-time-string "%FT%T%z" time-value))
+ (msg-str (format-time-string "%d-%m-%y at %H:%M[%z]" time-value)))
+ (if (not reschedule)
+ (progn
+ (setq-local mastodon-toot--scheduled-for iso8601-str)
+ (message (format "Toot scheduled for %s." msg-str)))
+ (let* ((args (when reschedule `(("scheduled_at" . ,iso8601-str))))
+ (url (when reschedule (mastodon-http--api
+ (format "scheduled_statuses/%s" id))))
+ (response (mastodon-http--put url args)))
+ (mastodon-http--triage response
+ (lambda ()
+ ;; reschedule means we are in scheduled toots view:
+ (mastodon-tl--view-scheduled-toots)
+ (message
+ (format "Toot rescheduled for %s." msg-str)))))))))
(defun mastodon-toot--iso-to-human (ts)
"Format an ISO8601 timestamp TS to be more human-readable."