Commit 84c47370 authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Separated initialization for core and backend

core initialization does not need to go through the same import process
as backend, and this might be triggering issues if both get executed at
the same time (as both would modify storage).
parent a5200442
{
"name": "Booklet",
"name": "Relevance",
"version": "0.2",
"browser_action": {
"default_title": "Show the popup",
"default_title": "Show history",
"scripts": ["booklet.js", "handler.js"],
"default_icon": {
"19": "icon19.png",
......
......@@ -77,6 +77,13 @@
;;;;-------------------------------------
(register-handler
::initialize
(fn [_]
(go (dispatch [:data-import (:data (<! (storage/get)))]))
{:app-state {}}))
;; :data-import currently gets dispatched from both booklet.core
;; and booklet.background, not entirely happy with that. Needs
;; further clean up
......@@ -146,8 +153,8 @@
(register-handler
:handle-deactivation
(fn
; We get two parameters: the tab, and optionally the time at which it
; was deactivated (which defaults to now)
;; We get two parameters: the tab, and optionally the time at which it
;; was deactivated (which defaults to now)
[app-state [_ tab end-time]]
(console/trace " Deactivating " tab)
(when (or (:active tab)
......@@ -294,7 +301,7 @@
(defn init-time-tracking []
(go (let [state (<! (idle/query-state 30))
window (<! (windows/get-last-focused {:populate false}))]
(dispatch-sync [:initialize])
(dispatch-sync [::initialize])
(dispatch-sync [::window-focus {:windowId (:id window)}])
(dispatch-sync [:idle-state-change {:newState state}])
))
......
......@@ -59,9 +59,10 @@
(register-handler
:initialize
::initialize
(fn [_]
(go (dispatch [:data-import (:data (<! (storage/get)))]))
;; Fake a ::storage-changed message to load the data from storage
(go (dispatch [::storage-changed {:changes {:data {:newValue (:data (<! (storage/get)))}}}]))
{:app-state {}
:ui-state {:section :time-track}}))
......@@ -257,7 +258,7 @@
(defn init []
(dispatch-sync [:initialize])
(dispatch-sync [::initialize])
(on-channel storage/on-changed dispatch ::storage-changed)
(idle/set-detection-interval 60)
(mount-components))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment