diff --git a/frontend/src/app/main/data/team.cljs b/frontend/src/app/main/data/team.cljs index 74805e380..6cbccc054 100644 --- a/frontend/src/app/main/data/team.cljs +++ b/frontend/src/app/main/data/team.cljs @@ -127,7 +127,7 @@ ptk/WatchEvent (watch [_ _ stream] - (let [stopper (rx/filter (ptk/type? ::finalize) stream)] + (let [stopper (rx/filter (ptk/type? ::finalize-team) stream)] (->> (rx/merge (rx/of (fetch-teams)) (->> stream diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 526727345..0580ce640 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -267,30 +267,34 @@ [project-id file-id] (ptk/reify ::fetch-bundle-stage-1 ptk/WatchEvent - (watch [_ _ stream] - (->> (rp/cmd! :get-project {:id project-id}) - (rx/mapcat (fn [project] - (rx/concat - ;; Wait the wasm module to be loaded or failed to - ;; load. We need to wait the promise to be resolved - ;; before continue with the next workspace loading - ;; steps - (->> (rx/from wasm/module) - (rx/ignore)) + (watch [_ state stream] + (let [render-wasm? (features/active-feature? state "render-wasm/v1")] + (->> (rp/cmd! :get-project {:id project-id}) + (rx/mapcat (fn [project] + (rx/concat + ;; Wait the wasm module to be loaded or failed to + ;; load. We need to wait the promise to be resolved + ;; before continue with the next workspace loading + ;; steps - (->> (rp/cmd! :get-team {:id (:team-id project)}) - (rx/mapcat (fn [team] - (let [bundle {:team team - :project project - :file-id file-id - :project-id project-id}] - ;; FIXME: this should not be handled here, pending - ;; refactor of urls and team initialization - ;; normalization - (rx/of (dtm/set-current-team team) - (ptk/data-event ::bundle-stage-1 bundle))))))))) - (rx/take-until - (rx/filter (ptk/type? ::fetch-bundle) stream)))))) + (if ^boolean render-wasm? + (->> (rx/from @wasm/module) + (rx/ignore)) + (rx/empty)) + + (->> (rp/cmd! :get-team {:id (:team-id project)}) + (rx/mapcat (fn [team] + (let [bundle {:team team + :project project + :file-id file-id + :project-id project-id}] + ;; FIXME: this should not be handled here, pending + ;; refactor of urls and team initialization + ;; normalization + (rx/of (dtm/set-current-team team) + (ptk/data-event ::bundle-stage-1 bundle))))))))) + (rx/take-until + (rx/filter (ptk/type? ::fetch-bundle) stream))))))) (defn- fetch-bundle-stage-2 [{:keys [file-id project-id project] :as bundle}] diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index 65a5a7fc8..54171edf1 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -239,16 +239,17 @@ (set! (.-height canvas) (* dpr (.-clientHeight ^js canvas)))) (defonce module - (if (exists? js/dynamicImport) - (let [uri (cf/resolve-static-asset "js/render_wasm.js")] - (->> (js/dynamicImport (str uri)) - (p/mcat (fn [module] - (let [default (unchecked-get module "default")] - (default)))) - (p/fmap (fn [module] - (set! internal-module module) - true)) - (p/merr (fn [cause] - (js/console.error cause) - (p/resolved false))))) - (p/resolved false))) + (delay + (if (exists? js/dynamicImport) + (let [uri (cf/resolve-static-asset "js/render_wasm.js")] + (->> (js/dynamicImport (str uri)) + (p/mcat (fn [module] + (let [default (unchecked-get module "default")] + (default)))) + (p/fmap (fn [module] + (set! internal-module module) + true)) + (p/merr (fn [cause] + (js/console.error cause) + (p/resolved false))))) + (p/resolved false))))