1
0
Fork 0

- [TUI][fediverse] ensured the printed status is updated after editing.

This commit is contained in:
cage 2024-06-27 13:55:39 +02:00
parent 0f5fe10ab6
commit ebbee28430
3 changed files with 38 additions and 21 deletions

View File

@ -501,13 +501,15 @@ become an emty string (\"\")
:limit limit :limit limit
:min-id max-id)))) :min-id max-id))))
(defun-api-call fetch-remote-status (status-id) (defun-api-call fetch-remote-status (status-id &optional folder timeline)
"Fetch a single status identified by status-id and generate an event "Fetch a single status identified by status-id and generate an event
`fetch-remote-status-event' that, in turn will save the status to the `fetch-remote-status-event' that, in turn will save the status to the
database." database."
(when-let* ((status (tooter:find-status *client* status-id)) (when-let* ((status (tooter:find-status *client* status-id))
(event (make-instance 'program-events:fetch-remote-status-event (event (make-instance 'program-events:fetch-remote-status-event
:payload status))) :payload status
:folder folder
:timeline timeline)))
(program-events:push-event event))) (program-events:push-event event)))
(defun-api-call get-remote-status (status-id) (defun-api-call get-remote-status (status-id)

View File

@ -556,15 +556,25 @@
(going-backward (going-backward
(ui:update-current-timeline-backwards (1+ recover-count))))))))) (ui:update-current-timeline-backwards (1+ recover-count)))))))))
(defclass fetch-remote-status-event (program-event) ()) (defclass fetch-remote-status-event (program-event)
((timeline
:initform nil
:initarg :timeline
:accessor timeline)
(folder
:initform nil
:initarg :folder
:accessor folder)))
(defmethod process-event ((object fetch-remote-status-event)) (defmethod process-event ((object fetch-remote-status-event))
(let ((status (payload object))) (let ((status (payload object)))
#+debug-mode (with-accessors ((folder folder)
(let ((dump (with-output-to-string (stream) (timeline timeline)) object
(tooter::present status stream)))) #+debug-mode
(dbg "fetch single status ~a" dump)) (let ((dump (with-output-to-string (stream)
(db:update-db status))) (tooter::present status stream))))
(dbg "fetch single status ~a" dump))
(db:update-db status :folder folder :timeline timeline))))
(defparameter *search-next-saved-event* nil) (defparameter *search-next-saved-event* nil)
@ -2068,9 +2078,12 @@
(defmethod process-event ((object edit-status-event)) (defmethod process-event ((object edit-status-event))
(with-accessors ((status-id payload)) object (with-accessors ((status-id payload)) object
(when-let* ((status (db:find-status-id status-id)) (when-let* ((status (db:find-status-id status-id))
(text (db:row-message-rendered-text status)) (text (db:row-message-rendered-text status))
(status-id (db:row-message-status-id status))) (status-id (db:row-message-status-id status))
(folder (db:row-message-folder status))
(timeline (db:row-message-timeline status))
(message-index (db:row-message-index status)))
(let ((temp-file (fs:temporary-file))) (let ((temp-file (fs:temporary-file)))
(with-open-file (stream temp-file (with-open-file (stream temp-file
:direction :output :direction :output
@ -2080,15 +2093,16 @@
(croatoan:end-screen) (croatoan:end-screen)
(tui:with-notify-errors (tui:with-notify-errors
(os-utils:open-with-editor temp-file)) (os-utils:open-with-editor temp-file))
(let* ((new-content (fs:slurp-file temp-file)) (let ((new-content (fs:slurp-file temp-file)))
(raw-rows (text-utils:split-lines new-content))) (ui:notify (_ "Editing post…"))
(message-window:prepare-for-rendering specials:*message-window* raw-rows) (client:edit-status status-id new-content nil nil nil nil)
(windows:win-clear specials:*message-window*) (db:remove-from-status-ignored status-id folder timeline)
(windows:draw specials:*message-window*) (db::delete-status timeline folder status-id)
(ui:with-blocking-notify-procedure ((_ "Editing post…") (client:fetch-remote-status status-id folder timeline)
(_ "Post modified")) (ui:refresh-thread)
(api-client:edit-status status-id new-content nil nil nil nil) (with-enqueued-process (+minimum-event-priority+)
(client:fetch-remote-status status-id))))))) (ui:thread-open-selected-message)
(ui:notify (_ "Post modified"))))))))
;;;; end events ;;;; end events

View File

@ -955,7 +955,8 @@ Starting from the oldest toot and going back."
:new-timeline timeline :new-timeline timeline
:status-id status-id)) :status-id status-id))
(refresh-event (make-instance 'refresh-thread-windows-event (refresh-event (make-instance 'refresh-thread-windows-event
:priority +minimum-event-priority+ :priority
(1+ +standard-event-priority+)
:message-status-id status-id))) :message-status-id status-id)))
(push-event expand-event) (push-event expand-event)
(push-event refresh-event)))) (push-event refresh-event))))