 (register-handler
   :on-relevance-sort-tabs
   (fn [app-state [_ tab]]
-    (sort-tabs! (:windowId tab) (get-in app-state url-time-path))
+    (sort-tabs! (:windowId tab) (:data app-state))
     app-state))
 
 



(def window-alarm "window-alarm")

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


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

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

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

          (tabs/create {:url ext-url})))))


(defn sort-tabs! [window-id data]
  (go
    (let [{:keys [url-times site-times]} data
          tabs (->> (:tabs (<! (windows/get window-id)))
                    (map #(assoc % :time (or (when-let [time (:time (get url-times (url-key (:url %))))]
                                               (+ time (:time (get site-times (host-key (hostname (:url %)))))))
                                             (- 2000 (:index %)))))
                    (sort-by #(* -1 (:time %)))
                    (map-indexed #(hash-map :index %1
