 (fx/defn update-browser-name
   [cofx title]
   (let [browser (get-current-browser (:db cofx))]
-    (when (and (not (:dapp? browser)) title (not (string/blank? title)))
+    (when (and browser (not (:dapp? browser)) title (not (string/blank? title)))
       (update-browser cofx (assoc browser :name title)))))
 
 (fx/defn navigation-state-changed

  [cofx browser url]
  (let [history-index (:history-index browser)
        history       (:history browser)]
    (let [new-history (conj (subvec history 0 (inc history-index)) url)
          new-index   (dec (count new-history))]
      (update-browser cofx
                      (assoc browser
                             :history new-history
                             :history-index new-index)))))

(defmulti storage-gateway :namespace)


  {:events [:browser.ui/open-empty-tab]}
  [cofx]
  (debounce/clear :browser/navigation-state-changed)
  (navigation/navigate-to-cofx cofx :empty-tab nil))
