           (tabs/create {:url ext-url})))))
 
 
-(defn sort-tabs! [window-id url-times]
+(defn sort-tabs! [window-id data]
   (go
-    (let [tabs (->> (:tabs (<! (windows/get window-id)))
-                    (map #(assoc % :time (or (:time (get url-times (url-key (:url %))))
+    (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

  (:require [cljs.core.async :refer [>! <!]]
            [relevance.data :as data]
            [relevance.io :as io]
            [relevance.utils :refer [on-channel url-key]]
            [khroma.alarms :as alarms]
            [khroma.context-menus :as menus]
            [khroma.idle :as idle]

            [re-frame.core :refer [dispatch register-sub register-handler subscribe dispatch-sync]]
            [khroma.extension :as ext]
            [khroma.browser-action :as browser]
            )
  (:require-macros [cljs.core.async.macros :refer [go go-loop]]))


