|
277 | 277 | [:> (oget Modal :Footer)
|
278 | 278 | [:> Button {:variant "danger"
|
279 | 279 | :on-click #(cb-thread
|
280 |
| - #(do (swap! menu conj :hold) (%)) |
| 280 | + :do #(swap! menu conj :hold) |
281 | 281 | #(git/pull db @selected %)
|
282 |
| - #(do (swap! menu pop) (swap! menu pop)))} |
| 282 | + :do #(swap! menu pop) |
| 283 | + :do #(swap! menu pop))} |
283 | 284 | strings/PULL]
|
284 | 285 | [:> Button {:variant "secondary"
|
285 | 286 | :on-click #(swap! menu pop)}
|
|
307 | 308 | name]))]]]
|
308 | 309 | [:> (oget Modal :Footer)
|
309 | 310 | [:> Button {:on-click #(cb-thread
|
310 |
| - #(do (swap! menu conj :hold) (%)) |
| 311 | + :do #(swap! menu conj :hold) |
311 | 312 | #(git/push db @selected %)
|
312 |
| - #(do (swap! menu pop) (swap! menu pop)))} |
| 313 | + :do #(swap! menu pop) |
| 314 | + :do #(swap! menu pop))} |
313 | 315 | strings/PUSH]
|
314 | 316 | [:> Button {:variant "secondary"
|
315 | 317 | :on-click #(swap! menu pop)}
|
|
644 | 646 | (when (condp = style
|
645 | 647 | :simple (not= @text "")
|
646 | 648 | :upload @file)
|
647 |
| - (choice-callback @text @file) |
648 |
| - (swap! menu #(let [item (peek %) |
649 |
| - rest (pop %)] |
650 |
| - (if (and (coll? item) |
651 |
| - (= (count item) 2)) |
652 |
| - (conj rest (second item)) |
653 |
| - rest))))) |
| 649 | + (cb-thread |
| 650 | + :do #(swap! menu conj :hold) |
| 651 | + #(choice-callback @text @file %) |
| 652 | + :do #(swap! menu pop) |
| 653 | + #(swap! menu #(let [item (peek %) |
| 654 | + rest (pop %)] |
| 655 | + (if (and (coll? item) |
| 656 | + (= (count item) 2)) |
| 657 | + (conj rest (second item)) |
| 658 | + rest)))))) |
654 | 659 | ref (or ref #js {:current nil})]
|
655 | 660 | (when list-ref
|
656 | 661 | (reset! list-ref dir-list)) ; don't deref dir-list here
|
|
832 | 837 | [:> (oget Modal :Header) {:close-button true}
|
833 | 838 | [:h3 strings/ADD-RESOURCE]]
|
834 | 839 | [file-browser db strings/ADD-lower :upload
|
835 |
| - (fn [optname files] |
| 840 | + (fn [optname files cb] |
836 | 841 | (cb-loop (oget files :target.files)
|
837 | 842 | #(let [name (if (= optname "")
|
838 | 843 | (oget %2 :name)
|
|
843 | 848 | (js/path.join @file-browser-folder name)
|
844 | 849 | v %)))
|
845 | 850 | (.catch js/console.error)))
|
846 |
| - #()))]]) |
| 851 | + cb))]]) |
847 | 852 |
|
848 | 853 | (defn save-dialog [{:keys [menu
|
849 | 854 | file-browser-folder
|
|
859 | 864 | [:> (oget Modal :Header) {:close-button true}
|
860 | 865 | [:h3 strings/SAVE]]
|
861 | 866 | [file-browser db strings/SAVE :simple
|
862 |
| - (fn [file] |
| 867 | + (fn [file _ cb] |
863 | 868 | (reset! current-folder @file-browser-folder)
|
864 | 869 | (reset! current-file file)
|
865 |
| - (save-buffer db)) |
| 870 | + (save-buffer db cb)) |
866 | 871 | {:file-browser fb-ref
|
867 | 872 | :file-browser-list fb-list-ref}]]))
|
868 | 873 |
|
|
880 | 885 | [:h3 strings/LOAD]]
|
881 | 886 | [:> (oget Modal :Body)
|
882 | 887 | [file-browser db strings/LOAD :simple
|
883 |
| - (fn [file] |
| 888 | + (fn [file _ cb] |
884 | 889 | (reset! current-folder @file-browser-folder)
|
885 | 890 | (reset! current-file file)
|
886 |
| - (load-buffer db)) |
| 891 | + (load-buffer db cb)) |
887 | 892 | {:file-browser fb-ref
|
888 | 893 | :file-browser-list fb-list-ref}]]])
|
889 | 894 |
|
|
1160 | 1165 | editor-reset-ref :editor-reset
|
1161 | 1166 | visr-run-ref :visr-run}]]
|
1162 | 1167 | (let [edit (atom nil)
|
1163 |
| - cache (atom nil) |
| 1168 | + cache (env/make-reset-editors-cache) |
1164 | 1169 | visrs (atom {})
|
1165 | 1170 | key (random-uuid)
|
1166 | 1171 | set-text (fn [txt]
|
|
1176 | 1181 | (let [fc @file-changed]
|
1177 | 1182 | (set! js/window.edit @edit)
|
1178 | 1183 | (-> @edit (ocall :getDoc) (ocall :setValue @input))
|
1179 |
| - (reset! cache nil) |
| 1184 | + ;; TODO, this should probably be uncommented? |
| 1185 | + ;; (env/make-reset-editors-cache cache) |
1180 | 1186 | (reset! file-changed fc))))
|
1181 |
| - reset-queue (clojure.core/atom #queue []) |
1182 | 1187 | codemirror-options #(conj (env/codemirror-options db) print-options)]
|
1183 | 1188 | (add-watch current-file key watch-updater)
|
1184 | 1189 | (add-watch menu key watch-updater)
|
|
1198 | 1203 | (add-watch deps key
|
1199 | 1204 | (fn [k r o n]
|
1200 | 1205 | (when-not (= o n)
|
1201 |
| - (reset! cache nil) |
| 1206 | + (env/make-reset-editors-cache cache) |
1202 | 1207 | (doseq [[k v] @visrs]
|
1203 | 1208 | (ocall @(:mark v) :clear))
|
1204 | 1209 | (reset! visrs {})
|
1205 | 1210 | (when editor-reset-ref
|
1206 | 1211 | (reset! editor-reset-ref true))
|
1207 |
| - (env/reset-editors! @input set-text edit visrs nil cache |
1208 |
| - reset-queue (codemirror-options) db #() |
| 1212 | + (env/reset-editors! @input set-text edit visrs cache |
| 1213 | + (codemirror-options) db #() |
1209 | 1214 | {:for-print for-print
|
1210 | 1215 | :hider-bars hider-bars
|
1211 | 1216 | :visr-run visr-run-ref}))))
|
1212 |
| - (add-watch reset-queue ::set-running? |
| 1217 | + (add-watch cache ::set-running? |
1213 | 1218 | (fn [k r o n]
|
1214 |
| - (when (and editor-reset-ref (empty? n)) |
| 1219 | + (when (and editor-reset-ref (empty? (:queue n))) |
1215 | 1220 | (reset! editor-reset-ref false))))
|
1216 | 1221 | (reset! visr-commit!
|
1217 | 1222 | (doseq [[k v] @visrs]
|
|
1250 | 1255 | (reset! input value)
|
1251 | 1256 | (when editor-reset-ref
|
1252 | 1257 | (reset! editor-reset-ref true))
|
1253 |
| - (env/reset-editors! @input set-text edit visrs operation |
1254 |
| - cache reset-queue (codemirror-options) db |
| 1258 | + (env/reset-editors! @input set-text edit visrs |
| 1259 | + cache (codemirror-options) db |
1255 | 1260 | #() {:for-print for-print
|
1256 | 1261 | :hider-bars hider-bars
|
1257 | 1262 | :visr-run visr-run-ref}))
|
|
1288 | 1293 | (reset! editor-ref e))
|
1289 | 1294 | (when editor-reset-ref
|
1290 | 1295 | (reset! editor-reset-ref true))
|
1291 |
| - (env/reset-editors! @input set-text edit visrs nil |
1292 |
| - cache reset-queue |
1293 |
| - (codemirror-options) db |
| 1296 | + (env/reset-editors! @input set-text edit visrs |
| 1297 | + cache (codemirror-options) db |
1294 | 1298 | #(reset! mounted? true)
|
1295 | 1299 | {:for-print for-print
|
1296 | 1300 | :hider-bars hider-bars
|
|
1308 | 1312 | :as db}
|
1309 | 1313 | & [repl-ref]]
|
1310 | 1314 | (let [edit (atom nil)
|
| 1315 | + cache (env/make-reset-editors-cache) |
1311 | 1316 | instances (atom [])
|
1312 | 1317 | watch-updater
|
1313 | 1318 | (fn [k r o n]
|
|
0 commit comments