 (ns tourneybot-client.core
   (:require
-    cljsjs.marked
-    cljsjs.moment
+    [cljsjs.marked]
+    [cljsjs.moment]
     [clojure.string :refer [blank? lower-case]]
     [goog.functions :refer [once]]
-    [tourneybot.data :refer [scheduled-status in-progress-status finished-status game-statuses
+    [rum.core :as rum]
+    [tourneybot.data :refer [ensure-tournament-state
+                             finished-status
+                             game-finished?
+                             game-statuses
                              games->results
-                             ensure-tournament-state
-                             game-finished?]]
-    [tourneybot.util :refer [atom-logger by-id js-log log fetch-ajax-text
-                             fetch-json-as-cljs tourney-bot-url
-                             game->date]]
-    [rum.core :as rum]))
+                             in-progress-status
+                             scheduled-status]]
+    [tourneybot.util :refer [atom-logger
+                             by-id
+                             fetch-ajax-text
+                             fetch-json-as-cljs
+                             game->date
+                             js-log
+                             log
+                             tourney-bot-url]]))
 
 ;;------------------------------------------------------------------------------
 ;; Constants

;;------------------------------------------------------------------------------

(def init-page!
  (once (fn []
          (fetch-tourney-state!)
          (fetch-info-page!)
          ;; trigger an initial render
          (swap! page-state identity))))

(init-page!)

(defn- on-change-page-state
  "Render the page on every state change."
  [_kwd _the-atom _old-state new-state]
  (rum/mount (IndexApp new-state) app-container-el))

(add-watch page-state :main on-change-page-state)

