Display a different message for an update rather than create

This commit is contained in:
Tom Willemse 2023-12-07 21:59:45 -08:00
parent d41e65e406
commit 0f663fabc6

View file

@ -93,7 +93,7 @@
data data
"&")) "&"))
(defun tekuti--send-finished (status buffer args) (defun tekuti--send-finished (status buffer args updatep)
(pcase-exhaustive status (pcase-exhaustive status
(`(:redirect ,url . ,_) (`(:redirect ,url . ,_)
(save-excursion (save-excursion
@ -117,9 +117,9 @@
(car (url-path-and-query (car (url-path-and-query
(url-generic-parse-url url)))) (url-generic-parse-url url))))
"\n")))) "\n"))))
(message "Created new post: %s" url)) (message "%s post: %s" (if updatep "Updated" "Created new") url))
(`(:error (error http ,code) . ,_) (`(:error (error http ,code) . ,_)
(message "Failed to create post: %d" code)))) (message "Failed to %s post: %d" (if updatep "update" "create") code))))
(defun tekuti--get-update-url () (defun tekuti--get-update-url ()
(save-excursion (save-excursion
@ -133,12 +133,14 @@
(url-request-method "POST") (url-request-method "POST")
(url-request-extra-headers (url-request-extra-headers
`(("Content-Type" . "application/x-www-form-urlencoded"))) `(("Content-Type" . "application/x-www-form-urlencoded")))
(url-request-data (tekuti-form-encode-data data))) (url-request-data (tekuti-form-encode-data data))
(previous-update-url (tekuti--get-update-url))
(updatep (not (null previous-update-url))))
(url-retrieve (format "%s%s" tekuti-host (url-retrieve (format "%s%s" tekuti-host
(or (tekuti--get-update-url) (or previous-update-url
"/admin/new-post")) "/admin/new-post"))
#'tekuti--send-finished #'tekuti--send-finished
(list (current-buffer) data)))) (list (current-buffer) data updatep))))
(provide 'tekuti) (provide 'tekuti)
;;; tekuti.el ends here ;;; tekuti.el ends here