    {:email-template (get action "template")}
     github-issue-init-state))
 
-(defmethod get-init-state-by-action "github-issue" [action]
-  (let [repo (split (get action "repo") "/")
-        user (first repo)
-        repository (second repo)]    
+(defmethod get-init-state-by-action "github-issue" [action]  
   (merge
    {:gh-issue-title (get action "title")
     :gh-issue-body (get action "body")
-    :gh-user user
-    :gh-repo repository}
-   email-init-state)))
+    :gh-repo (get action "repo")}
+   email-init-state))
 
 (defmethod get-init-state :update [data _]
   (let [action (:action data)]

(def email-init-state {:email-template default-email-template})
(def github-issue-init-state 
  {:gh-repo "" 
   :gh-user ""
   :gh-issue-title default-github-issue-title 
   :gh-issue-body default-github-issue-body})


                                           :value (:template data)
                                           :onChange #((:template-handler data) (.. % -target -value))}))))))

(defn github-issue-on-change [gh-repo timer form-handler form-status-handler error-handler]
  (js/clearTimeout timer)  
  
  (let [pr (split gh-repo "/")
        user (first pr)
        repo (second pr)]
    (form-handler 
     (if (or (nil? repo)
             (nil? user)
             (= "" user)
             (= "" repo))
       (do
         (form-status-handler "has-warning")
         nil)

       (js/setTimeout
        (fn [] 
          (action/get-github-repos 
           user 
           (fn [reply] 
             (let [rest (js->clj reply)
                   result (->> rest
                               (map #(get % "name"))
                               (filter #(= % repo)))]
               (if (first result)
                 (form-status-handler "has-success")
                 (form-status-handler "has-error"))))
           error-handler))
        1000)))))

(defn github-issue-component [data owner]
  (reify
    om/IInitState
    (init-state [this]
      {:form-status 
       (let [v (:value (:repo data))]
         (if (or (nil? v) (= "" v))
           "has-warning"
           "has-success"))
