Reopen external window when reloading the application

Fixes #104
This commit is contained in:
Daniel Compton 2017-11-27 16:39:23 +13:00
parent 7d1062319d
commit 9d7be2c845
3 changed files with 20 additions and 9 deletions

View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. This change
### Changed
* Switched from LESS to Garden styles. Now interactive development and debugging of re-frame-trace is even faster.
* Reopen/reattach external popup windows when reloading host application
## [0.1.13] - 2017-11-23

View File

@ -8,13 +8,17 @@
selected-tab (localstorage/get "selected-tab" :traces)
filter-items (localstorage/get "filter-items" [])
app-db-paths (localstorage/get "app-db-paths" '())
json-ml-paths (localstorage/get "app-db-json-ml-expansions" #{})]
json-ml-paths (localstorage/get "app-db-json-ml-expansions" #{})
external-window? (localstorage/get "external-window?" false)
using-trace? (localstorage/get "using-trace?" true)]
(when using-trace?
(rf/dispatch [:global/enable-tracing]))
(rf/dispatch [:settings/panel-width% panel-width%])
(rf/dispatch [:settings/show-panel? show-panel?])
(rf/dispatch [:settings/selected-tab selected-tab])
(when external-window?
(rf/dispatch [:global/launch-external]))
(rf/dispatch [:traces/filter-items filter-items])
(rf/dispatch [:app-db/paths app-db-paths])
(rf/dispatch [:app-db/set-json-ml-paths json-ml-paths])
(rf/dispatch [:global/add-unload-hook])
(when show-panel?
(rf/dispatch [:global/enable-tracing]))))
(rf/dispatch [:global/add-unload-hook])))

View File

@ -29,14 +29,18 @@
(rf/reg-event-db
:settings/user-toggle-panel
(fn [db _]
(let [show-panel? (not (get-in db [:settings :show-panel?]))
external-panel? (get-in db [:settings :external-window?])]
(if show-panel?
(let [now-showing? (not (get-in db [:settings :show-panel?]))
external-panel? (get-in db [:settings :external-window?])
using-trace? (or external-panel? now-showing?)]
(if now-showing?
(utils.traces/enable-tracing!)
(when-not external-panel?
(utils.traces/disable-tracing!)))
(localstorage/save! "show-panel" show-panel?)
(assoc-in db [:settings :show-panel?] show-panel?))))
(localstorage/save! "using-trace?" using-trace?)
(localstorage/save! "show-panel" now-showing?)
(-> db
(assoc-in [:settings :using-trace?] using-trace?)
(assoc-in [:settings :show-panel?] now-showing?)))))
;; Global
@ -69,6 +73,7 @@
:global/launch-external
(fn [ctx _]
(open-debugger-window)
(localstorage/save! "external-window?" true)
{:db (assoc-in (:db ctx) [:settings :external-window?] true)
;; TODO: capture the intent that the user is still interacting with devtools, to persist between reloads.
:dispatch-later [{:ms 200 :dispatch [:settings/show-panel? false]}]}))
@ -76,6 +81,7 @@
(rf/reg-event-fx
:global/external-closed
(fn [ctx _]
(localstorage/save! "external-window?" false)
{:db (assoc-in (:db ctx) [:settings :external-window?] false)
:dispatch-later [{:ms 400 :dispatch [:settings/show-panel? true]}]}))