 (register-handler
   ::initialize
   (fn [_]
-    (go (dispatch [:data-import (:data (<! (storage/get)))]))
-    {:app-state {}}))
+    (go
+      (dispatch [:data-import (:data (<! (storage/get))) true])
+      (dispatch [::window-focus {:windowId (:windowId (<! (windows/get-last-focused {:populate false})))}])
+      (dispatch [:idle-state-change {:newState (<! (idle/query-state 30))}]))
+    {:app-state    {}
+     :hookup-done? false}))
 
 
 ;; :data-import currently gets dispatched from both booklet.core

                 (not= (:id last-focused) (:windowId tab)))
        (dispatch [::window-focus {:windowId (:id last-focused)}])))))

(defn process-tab
  "Filters a tab down to the relevant keys, and adds a start time which is
  now if the tab is active, or 0 otherwise.

  Keeping the time on the tab itself, since we may end up with multiple tabs
  open to the same URL. Might make sense to track it all in one, using always
  the last one... but for now I'm assuming that if you have it active in two
  tabs, it's doubly important (you found it twice and forgot about it)."
  [tab]
  (->
    tab
    select-tab-keys
    add-tab-times))


(defn tab-list-to-map
  [tabs]
  (reduce #(assoc % (:id %2) %2) {} tabs))

(defn process-tabs
  "Take the tabs we have, filter them down and return them grouped by id."
  [tabs]
  (->>
    tabs
    (map process-tab)
    tab-list-to-map))


;;;;-------------------------------------




;;;;-------------------------------------
;;;; Settings
;;;;-------------------------------------


(def window-alarm "window-alarm")

(defn now [] (.now js/Date))


(def relevant-tab-keys [:windowId :id :active :url :selected :start-time :title :favIconUrl])

(def select-tab-keys #(select-keys % relevant-tab-keys))
(def url-time-path [:data :url-times])

;;;;-------------------------------------
;;;; Functions
;;;;-------------------------------------


(defn check-window-status
