mirror of https://codeberg.org/cage/tinmop/
- [TUI] added command 'edit-posted-message'.
This commit is contained in:
parent
eb85a63430
commit
0f5fe10ab6
|
@ -352,6 +352,8 @@
|
|||
|
||||
(define-key "T d" #'thread-delete-subtree *thread-keymap*)
|
||||
|
||||
(define-key "e" #'edit-posted-message *thread-keymap*)
|
||||
|
||||
(define-key "P" #'poll-vote *thread-keymap*)
|
||||
|
||||
(define-key "p" #'show-parent-post *thread-keymap*)
|
||||
|
|
|
@ -547,7 +547,8 @@ database."
|
|||
:spoiler-text subject
|
||||
:visibility visibility))
|
||||
|
||||
(defun-api-call edit-status (content
|
||||
(defun-api-call edit-status (status-id
|
||||
content
|
||||
attachments
|
||||
attachments-alt-text
|
||||
subject
|
||||
|
@ -558,6 +559,7 @@ database."
|
|||
to this message exists
|
||||
- subject the subject of this message"
|
||||
(tooter:edit-status *client*
|
||||
status-id
|
||||
content
|
||||
:language language
|
||||
:media (mapcar (lambda (path alt-text)
|
||||
|
|
|
@ -1805,6 +1805,7 @@
|
|||
:fediverse-query-event
|
||||
:fediverse-local-query-event
|
||||
:delete-all-notifications-event
|
||||
:edit-status-event
|
||||
:dispatch-program-events
|
||||
:dispatch-program-events-or-wait))
|
||||
|
||||
|
@ -3052,6 +3053,7 @@
|
|||
:send-message
|
||||
:compose-message
|
||||
:reply-message
|
||||
:edit-posted-message
|
||||
:open-message-attach
|
||||
:open-all-message-attachments
|
||||
:open-message-attach-go-up
|
||||
|
|
|
@ -2064,6 +2064,32 @@
|
|||
:new-timeline db:+home-timeline+)))
|
||||
(push-event refresh-event)))))))
|
||||
|
||||
(defclass edit-status-event (program-event) ())
|
||||
|
||||
(defmethod process-event ((object edit-status-event))
|
||||
(with-accessors ((status-id payload)) object
|
||||
(when-let* ((status (db:find-status-id status-id))
|
||||
(text (db:row-message-rendered-text status))
|
||||
(status-id (db:row-message-status-id status)))
|
||||
(let ((temp-file (fs:temporary-file)))
|
||||
(with-open-file (stream temp-file
|
||||
:direction :output
|
||||
:if-exists :supersede
|
||||
:if-does-not-exist :create)
|
||||
(write-sequence text stream))
|
||||
(croatoan:end-screen)
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file))
|
||||
(let* ((new-content (fs:slurp-file temp-file))
|
||||
(raw-rows (text-utils:split-lines new-content)))
|
||||
(message-window:prepare-for-rendering specials:*message-window* raw-rows)
|
||||
(windows:win-clear specials:*message-window*)
|
||||
(windows:draw specials:*message-window*)
|
||||
(ui:with-blocking-notify-procedure ((_ "Editing post…")
|
||||
(_ "Post modified"))
|
||||
(api-client:edit-status status-id new-content nil nil nil nil)
|
||||
(client:fetch-remote-status status-id)))))))
|
||||
|
||||
;;;; end events
|
||||
|
||||
(defun dispatch-program-events ()
|
||||
|
|
|
@ -1447,6 +1447,13 @@ It an existing file path is provided the command will refuse to run."
|
|||
(add-language)))))))
|
||||
(add-body)))
|
||||
|
||||
(defun edit-posted-message ()
|
||||
(when-let* ((win *thread-window*)
|
||||
(selected-message (line-oriented-window:selected-row-fields win))
|
||||
(status-id (db:row-message-status-id selected-message)))
|
||||
(push-event (make-instance 'edit-status-event
|
||||
:payload status-id))))
|
||||
|
||||
(defun actual-author-message-id (message-row)
|
||||
(or (db:row-message-reblog-id message-row)
|
||||
(db:row-message-status-id message-row)))
|
||||
|
|
Loading…
Reference in New Issue