 
 (defn properties-div [data owner]
   (reify
-    om/IDidUpdate
-    (did-update [_ prev-props prev-state]
-      (let [{:keys [projects properties active-components]} data
-            new-project_id (:projects active-components)]
-
-        ;; handle selection in projects table
-        (when-not new-project_id
-          (om/update! properties :data [])
-          (om/update! properties :selected nil))
-
-        (if (and new-project_id
-                 (not (= (:project_id properties) new-project_id)))
-          (do
-            (om/update! properties :fetching :fetching)
-            (GET (str "/4/projects/" new-project_id "/properties/")
-                 {:handler  (fn [x]
-                              ;; (println "Fetching properties for project: " new-project_id)
-                              (om/update! properties :data (mapv slugify-property x))
-                              (om/update! properties :fetching (if (empty? x) :no-data :has-data))
-                              (om/update! properties :selected nil))
-                  :error-handler (fn [{:keys [status status-text]}]
-                                   (om/update! properties :fetching :error)
-                                   (om/update! properties :error-status status)
-                                   (om/update! properties :error-text status-text))
-                  :headers {"Accept" "application/edn"}
-                  :response-format :text})))
-        (om/update! properties :project_id new-project_id)
-
-        ;; handle selection on properties table
-        (om/update! properties :selected (:properties active-components))))
     om/IRender
     (render [_]
       (let [{:keys [programmes projects properties active-components]} data

        :headers {"Accept" "application/edn"}
        :response-format :text}))

(defn history-loop [history-channel data]
  (go-loop []
    (let [nav-event (<! history-channel)

        (println "Setting selected programme to: " programmes)
        (om/update! data [:programmes :selected] programmes)
        (fetch-projects programmes data))

      (when (and projects
                 (not= projects old-projects))
        (println "Setting selected project to: " projects)
        (om/update! data [:projects :selected] projects)
        (fetch-properties projects data))
      
      ;; Update the new active components
      (om/update! data :active-components (-> nav-event :args :ids)))
    (recur)))

