1
0
Fork 0

- added notify error when updating timelines fails.

This commit is contained in:
cage 2020-05-14 18:14:28 +02:00
parent dbdc2d9590
commit bc4d42d847
4 changed files with 35 additions and 32 deletions

View File

@ -679,7 +679,8 @@
:attribute-invisible :attribute-invisible
:combine-attributes :combine-attributes
:colorize-line :colorize-line
:colorized-line->tui-string)) :colorized-line->tui-string
:with-notify-errors))
(defpackage :db (defpackage :db
(:use (:use

View File

@ -33,15 +33,6 @@
(incf *event-id*) (incf *event-id*)
*event-id*) *event-id*)
(defmacro with-notify-errors (&body body)
`(handler-case
(progn
,@body)
(error (e)
(ui:notify (format nil (_ "Error: ~a") e)
:life (* (swconf:config-notification-life) 5)
:as-error t))))
(defclass program-event () (defclass program-event ()
((event-id ((event-id
:initform (next-id) :initform (next-id)
@ -461,25 +452,25 @@
(defclass favourite-status-event (program-event event-with-message-index) ()) (defclass favourite-status-event (program-event event-with-message-index) ())
(defmethod process-event ((object favourite-status-event)) (defmethod process-event ((object favourite-status-event))
(with-notify-errors (tui:with-notify-errors
(change-status-values object #'api-client:favourite-status))) (change-status-values object #'api-client:favourite-status)))
(defclass unfavourite-status-event (program-event event-with-message-index) ()) (defclass unfavourite-status-event (program-event event-with-message-index) ())
(defmethod process-event ((object unfavourite-status-event)) (defmethod process-event ((object unfavourite-status-event))
(with-notify-errors (tui:with-notify-errors
(change-status-values object #'api-client:unfavourite-status))) (change-status-values object #'api-client:unfavourite-status)))
(defclass reblog-status-event (program-event event-with-message-index) ()) (defclass reblog-status-event (program-event event-with-message-index) ())
(defmethod process-event ((object reblog-status-event)) (defmethod process-event ((object reblog-status-event))
(with-notify-errors (tui:with-notify-errors
(change-status-values object #'api-client:reblog-status))) (change-status-values object #'api-client:reblog-status)))
(defclass unreblog-status-event (program-event event-with-message-index) ()) (defclass unreblog-status-event (program-event event-with-message-index) ())
(defmethod process-event ((object unreblog-status-event)) (defmethod process-event ((object unreblog-status-event))
(with-notify-errors (tui:with-notify-errors
(change-status-values object #'api-client:unreblog-status))) (change-status-values object #'api-client:unreblog-status)))
(defclass unignore-user-event (program-event) ()) (defclass unignore-user-event (program-event) ())
@ -584,7 +575,7 @@
(defclass open-follow-requests-window-event (program-event) ()) (defclass open-follow-requests-window-event (program-event) ())
(defmethod process-event ((object open-follow-requests-window-event)) (defmethod process-event ((object open-follow-requests-window-event))
(with-notify-errors (tui:with-notify-errors
(multiple-value-bind (accounts usernames) (multiple-value-bind (accounts usernames)
(api-client:follow-requests) (api-client:follow-requests)
(when accounts (when accounts
@ -662,7 +653,7 @@
(defmethod process-event ((object update-conversations-event)) (defmethod process-event ((object update-conversations-event))
(with-accessors ((new-timeline new-timeline) (with-accessors ((new-timeline new-timeline)
(new-folder new-folder)) object (new-folder new-folder)) object
(with-notify-errors (tui:with-notify-errors
(add-new-conversations) (add-new-conversations)
(let* ((all-conversations (db:all-conversations))) (let* ((all-conversations (db:all-conversations)))
(loop for conversation in all-conversations do (loop for conversation in all-conversations do
@ -716,7 +707,7 @@
(folder (line-oriented-window:normal-text selected-row)) (folder (line-oriented-window:normal-text selected-row))
(id (db:conversation-id fields)) (id (db:conversation-id fields))
(refresh-event (make-instance 'refresh-conversations-window-event))) (refresh-event (make-instance 'refresh-conversations-window-event)))
(with-notify-errors (tui:with-notify-errors
(api-client:delete-conversation id) (api-client:delete-conversation id)
(db:delete-conversation folder)))) (db:delete-conversation folder))))
@ -743,7 +734,7 @@
(account-id account-id) (account-id account-id)
(comment comment) (comment comment)
(forwardp forwardp)) object (forwardp forwardp)) object
(with-notify-errors (tui:with-notify-errors
(api-client:make-report account-id status-id comment forwardp)))) (api-client:make-report account-id status-id comment forwardp))))
(defclass add-crypto-data-event (program-event) (defclass add-crypto-data-event (program-event)

View File

@ -467,3 +467,12 @@
(print-unreadable-object (object stream :type t :identity nil) (print-unreadable-object (object stream :type t :identity nil)
(loop for i across (complex-char-array object) do (loop for i across (complex-char-array object) do
(print-debug i)))) (print-debug i))))
(defmacro with-notify-errors (&body body)
`(handler-case
(progn
,@body)
(error (e)
(ui:notify (format nil (_ "Error: ~a") e)
:life (* (swconf:config-notification-life) 5)
:as-error t))))

View File

@ -474,13 +474,14 @@ and if fetch local (again, to server) statuses only."
(multiple-value-bind (kind localp) (multiple-value-bind (kind localp)
(timeline->kind timeline) (timeline->kind timeline)
(flet ((update () (flet ((update ()
(client:update-timeline timeline (with-notify-errors
kind (client:update-timeline timeline
folder kind
:min-id max-id folder
:local localp) :min-id max-id
(let ((refresh-event (make-instance 'refresh-thread-windows-event))) :local localp)
(push-event refresh-event)))) (let ((refresh-event (make-instance 'refresh-thread-windows-event)))
(push-event refresh-event)))))
(notify-procedure #'update (notify-procedure #'update
(_ "Downloading messages.") (_ "Downloading messages.")
:ending-message (_ "Messages downloaded.") :ending-message (_ "Messages downloaded.")
@ -496,13 +497,14 @@ Starting from the oldest toot and going back."
(multiple-value-bind (kind localp) (multiple-value-bind (kind localp)
(timeline->kind timeline) (timeline->kind timeline)
(flet ((update () (flet ((update ()
(client:update-timeline timeline (with-notify-errors
kind (client:update-timeline timeline
folder kind
:max-id min-id folder
:local localp) :max-id min-id
(let ((refresh-event (make-instance 'refresh-thread-windows-event))) :local localp)
(push-event refresh-event)))) (let ((refresh-event (make-instance 'refresh-thread-windows-event)))
(push-event refresh-event)))))
(notify-procedure #'update (notify-procedure #'update
(_ "Downloading messages.") (_ "Downloading messages.")
:ending-message (_ "Messages downloaded.") :ending-message (_ "Messages downloaded.")