made it possible to change layouts.

This commit is contained in:
Bryce Covert
2017-12-19 19:31:13 -08:00
parent 043e558a51
commit b1414ebe60
6 changed files with 120 additions and 54 deletions

View File

@@ -4,17 +4,11 @@
[auto-ap.events :as events]
[auto-ap.views :as views]
[auto-ap.config :as config]
[auto-ap.routes :as routes]
[auto-ap.effects :as effects]
[pushy.core :as pushy]
[auto-ap.pushy :as p]
[bidi.bidi :as bidi]))
(defn- parse-url [url]
(bidi/match-route routes/routes url))
(defn- dispatch-route [matched-route]
(re-frame/dispatch [::events/set-active-page (:handler matched-route)]))
(defn dev-setup []
(when true
(enable-console-print!)
@@ -22,16 +16,19 @@
(defn mount-root []
(re-frame/clear-subscription-cache!)
(reagent/render [views/main-panel]
(reagent/render [views/page]
(.getElementById js/document "app")))
(defn ^:export init []
(dev-setup)
(when-let [jwt (.get (js/URLSearchParams. (.-search (.-location js/window))) "jwt")]
(println "got jwt" jwt)
(.setItem js/localStorage "jwt" jwt))
(pushy/start! (pushy/pushy dispatch-route parse-url))
(re-frame/dispatch-sync [::events/initialize-db])
(pushy/start! p/history)
(if-let [jwt (.get (js/URLSearchParams. (.-search (.-location js/window))) "jwt")]
(do
(.setItem js/localStorage "jwt" jwt)
(re-frame/dispatch-sync [::events/initialize-db jwt]))
(do
(re-frame/dispatch-sync [::events/initialize-db nil])))
(mount-root))