aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-views.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-03-18 15:25:44 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-03-18 18:21:11 +0100
commit4a06f0c5c0cc8b70e51d6a816d55dc53fe7edcf8 (patch)
tree98e622d5152ba5422a75d3f9e77321f51c360563 /lisp/mastodon-views.el
parent393f700bc45ae713af48b40fedc422da4d986f57 (diff)
check for scheduled toot at point before action
fix reschedule check fix cancel scheduled toot rejig
Diffstat (limited to 'lisp/mastodon-views.el')
-rw-r--r--lisp/mastodon-views.el67
1 files changed, 35 insertions, 32 deletions
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index ed68528..45317cf 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -531,7 +531,10 @@ If ID, just return that toot."
(defun mastodon-views--reschedule-toot ()
"Reschedule the scheduled toot at point."
(interactive)
- (mastodon-toot--schedule-toot :reschedule))
+ (let ((id (get-text-property (point) 'id)))
+ (if (null id)
+ (message "no scheduled toot at point?")
+ (mastodon-toot--schedule-toot :reschedule))))
(defun mastodon-views--copy-scheduled-toot-text ()
"Copy the text of the scheduled toot at point."
@@ -546,41 +549,41 @@ If ID, just return that toot."
ID is that of the scheduled toot to cancel.
NO-CONFIRM means there is no ask or message, there is only do."
(interactive)
- (let* ((id (or id (get-text-property (point) 'id)))
- (url (mastodon-http--api (format "scheduled_statuses/%s" id))))
- (when (or no-confirm
- (y-or-n-p "Cancel scheduled toot?"))
- (let ((response (mastodon-http--delete url)))
- (mastodon-http--triage response
- (lambda ()
- (mastodon-views--view-scheduled-toots)
- (unless no-confirm
- (message "Toot cancelled!"))))))))
+ (let ((id (or id (get-text-property (point) 'id))))
+ (if (null id)
+ (message "no scheduled toot at point?")
+ (when (or no-confirm
+ (y-or-n-p "Cancel scheduled toot?"))
+ (let* ((url (mastodon-http--api (format "scheduled_statuses/%s" id)))
+ (response (mastodon-http--delete url)))
+ (mastodon-http--triage response
+ (lambda ()
+ (mastodon-views--view-scheduled-toots)
+ (unless no-confirm
+ (message "Toot cancelled!")))))))))
(defun mastodon-views--edit-scheduled-as-new ()
"Edit scheduled status as new toot."
(interactive)
- (let* ((toot (get-text-property (point) 'scheduled-json))
- (id (alist-get 'id toot))
- (scheduled (alist-get 'scheduled_at toot))
- (params (alist-get 'params toot))
- (text (alist-get 'text params))
- (visibility (alist-get 'visibility params))
- (cw (alist-get 'spoiler_text params))
- (lang (alist-get 'language params))
- ;; (poll (alist-get 'poll params))
- (reply-id (alist-get 'in_reply_to_id params)))
- ;; (media (alist-get 'media_attachments toot)))
- (mastodon-toot--compose-buffer)
- (goto-char (point-max))
- (insert text)
- ;; adopt properties from scheduled toot:
- (mastodon-toot--set-toot-properties reply-id visibility cw
- lang scheduled id)))
-
-
-;;; FILTERS
-
+ (let ((id (get-text-property (point) 'id)))
+ (if (null id)
+ (message "no scheduled toot at point?")
+ (let* ((toot (get-text-property (point) 'scheduled-json))
+ (scheduled (alist-get 'scheduled_at toot))
+ (params (alist-get 'params toot))
+ (text (alist-get 'text params))
+ (visibility (alist-get 'visibility params))
+ (cw (alist-get 'spoiler_text params))
+ (lang (alist-get 'language params))
+ ;; (poll (alist-get 'poll params))
+ (reply-id (alist-get 'in_reply_to_id params)))
+ ;; (media (alist-get 'media_attachments toot)))
+ (mastodon-toot--compose-buffer)
+ (goto-char (point-max))
+ (insert text)
+ ;; adopt properties from scheduled toot:
+ (mastodon-toot--set-toot-properties reply-id visibility cw
+ lang scheduled id)))))
;;; FILTERS