 
   ;(or (and (= (read-ui app [:mode]) "view") (large-screen)) (= (read-ui app [:mode]) "edit"))
 
-  (div {:style {:display (if (= (read-ui app [:mode]) "edit") "inline-block" "none")}}
+  (div {:style {:display (if (= (get-in @app-state  [:mode]) "edit") "inline-block" "none")}}
        (realtime select   id, application_name, application_glyph
-                 from appshare_applications where id = ? {:params [(read-ui app [:app-id])]}
+                 from appshare_applications where id = ? {:params [(get-in @app-state [:app-id])]}
 
                  (div {:style {:marginLeft "20px" :padding "5px"}}
                       (cond
-                        (= (read-ui app [:ui :ui :editor :mode]) "text")
-                        (span {:onClick #(go  (write-ui app [:ui :ui :editor :mode] "blockly")
+                        (= (get-in @app-state [:ui :editor :mode]) "text")
+                        (span {:onClick #(go  (swap! app-state assoc-in [:ui :editor :mode] "blockly")
                                               (js/setTimeout js/refreshBlockly 500)
-                                              (touch [:ui :editor])
+                                              (js/setTimeout (fn [ee] (touch [:ui :editor])) 500)
                                               )} "Text | ")
 
-                        (or (= (read-ui app [:ui :ui :editor :mode]) "blockly") (= (read-ui app [:ui :ui :editor :mode]) nil))
-                        (span {:onClick #(go  (write-ui app [:ui :ui :editor :mode] "text")
+                        (or (= (get-in @app-state [:ui :editor :mode]) "blockly") (= (get-in @app-state [:ui :editor :mode]) nil))
+                        (span {:onClick #(go  (swap! app-state assoc-in [:ui :editor :mode] "text")
                                               (js/setTimeout js/refreshCodeMirror 500)
                                               (touch [])
                                               )} "Blockly | ")

       (button {:style { :marginRight "30px" :marginBottom "10px" :marginTop "20px"}
                :className "btn-lg btn-default"
                :onClick     #(go
                                (write-ui app [:mode] "edit"))}
               "Cancel")

       ))

  (do

    (div {:style {
                   :display (if (or (= (get-in @app-state [:ui :editor :mode]) "blockly")
                                    (= (get-in @app-state [:ui :editor :mode]) nil))
                              "display-inline"
                              "none")

                   :background "white" :width "100%"  :height "800px" :align "top" :top "100px"  }}

