Skip to content

Commit

Permalink
fix saved and close event
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Dec 1, 2024
1 parent a27339b commit 9cb5059
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/renderer/document/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@
(if system/electron?
{::window.fx/ipc-invoke {:channel "save-document"
:data (pr-str document)
:on-success [::close-saved]
:on-success [::mark-as-saved-and-close]
:on-error [::notification.e/exception]
:formatter edn/read-string}}
{::app.fx/file-save {:data (h/save-format document)
:options file-picker-options
:formatter (fn [file] {:id id
:title (.-name file)})
:on-success [::close-saved]
:on-success [::mark-as-saved-and-close]
:on-error [::notification.e/exception]}}))))

(rf/reg-event-fx
Expand Down Expand Up @@ -300,7 +300,7 @@
db)))

(rf/reg-event-fx
::close-saved
::mark-as-saved-and-close
(fn [_ [_ document-info]]
{:dispatch-n [[::saved document-info]
[::close (:id document-info) false]]}))
Expand Down
4 changes: 2 additions & 2 deletions test/document_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(rf/dispatch [::e/init])

(testing "close"
(rf/dispatch [::e/close (:id @(rf/subscribe [::s/active]) false)])
(rf/dispatch [::e/close @(rf/subscribe [::s/active-id]) false])
(is (not @(rf/subscribe [::s/active]))))

(testing "close active"
Expand All @@ -34,7 +34,7 @@
(rf/dispatch [::e/close-active])
(is (not @(rf/subscribe [::s/active]))))

(testing "close all saved"
(testing "close saved"
(rf/dispatch [::e/new])
(rf/dispatch [::e/new])
(rf/dispatch [::e/saved @(rf/subscribe [::s/active])])
Expand Down

0 comments on commit 9cb5059

Please sign in to comment.