   (om/ref-cursor (:current-index (om/root-cursor app-state))))
 
 (defn registered-state-cur [index]
-  (om/ref-cursor (get (om/root-cursor app-state) [:registered-states index])))  
+  (om/ref-cursor (get-in (om/root-cursor app-state) [:registered-states index])))  
 
 ;; views
 (defn repo-list-view [state owner]

        (apply dom/div nil
          (map-indexed repo-button (:repos @app-state)))))))  

;; {:auth - :repo -}
(defn repo-config-panel [state owner]
  (reify
    om/IRender
    (render [this]
      (let [index (:index state)
            current-state (nth (om/observe owner (registered-state-cur index)) 0)
            auth-token (:auth state)
            register-repo-url (str/format "/api/user/%s/register" (get-in state [:repo "name"]))
            register-fn (fn [] 
                          (when (= current-state :unregistered)
                            (om/update! (registered-state-cur index) [0] :registering)  

                            (go (let [resp (<! (http/post register-repo-url {:oauth-token auth-token
                                                                             :json-params {}}))]
                                   (if (= 200 (:status resp))
                                     (prn resp)
                                     (om/update! (registered-state-cur index) [0] :unregistered))))))]      

        (case current-state
          :registered (dom/h2 nil (get (:repo state) "full_name"))
          :registering (dom/h2 
                          nil
                          "registering...")
          :unregistered (dom/button 
                          #js {:onClick register-fn}
                          "register this repo"))))))

;; {:repos - :auth -}

                                [:registered]
                                [:unregistered])
                          (:repos @app-state))]
        (swap! app-state (fn [state] (assoc state :registered-states registered)))))

    om/IRender
    (render [this]
      (let [current-index (nth (om/observe owner (current-index-cur)) 0)
            repos (:repos @app-state)]
        (if (< current-index (count repos))
          (om/build repo-config-panel {:index current-index
                                       :auth (:auth state)})                              
          (dom/h2 nil "Add your repos"))))))

