 (defn identity-token []
   (.getItem (.-localStorage js/window) "rmfu-feed-identity-token"))
 
+(def app-state (reagent/atom
+          {:alert                    {:display false
+                                      :message nil
+                                      :title   nil}}))
+
+(defn alert-update-display-fn [title msg]
+          (swap! app-state assoc
+          :alert {:title   title
+                  :message msg
+                  :display true}))
+
 (defn nav
   "Renders basic nav with an .active link"
   [active]

                [:li {:className "nav-item"}
                 [:a.nav-link.active {:href "/#/admin"} "Admin"]])]
             [:form.form-inline.navbar-form.pull-right
              [:button.btn.btn-success-outline {:type "button" :on-click #(logout)} "logout"]]]
            )])})))

         (if (identity-token)
           (GET "/api/user"
                {:headers         {:identity (identity-token)}
                 :error-handler   (fn []
                                    (logout)
                                    (alert-update-display-fn "Session Expired" "Your session has expired, redirecting to the sign-in sreen")
                                    #(secretary/dispatch! "/"))
                 :response-format :json
                 :keywords?       true
                 :handler         (fn [res]
                                    (session/put! :profile res))})))
       :reagent-render
       (fn []
         [:div
         [:nav {:className "navbar navbar-light bg-faded rmfu-nav"}
         [:a {:href "/#/feed"} [:img.navbar-brand.feed-logo {:src "/images/rmfu-logo.png"}]]
          (if-let [profile (session/get :profile)]
