|
|
@@ -1,7 +1,10 @@
|
|
|
(ns frontend.handler.events.ui
|
|
|
"UI events"
|
|
|
- (:require [frontend.components.block :as block]
|
|
|
+ (:require [clojure.core.async :as async]
|
|
|
+ [clojure.core.async.interop :refer [p->c]]
|
|
|
+ [frontend.components.block :as block]
|
|
|
[frontend.components.cmdk.core :as cmdk]
|
|
|
+ [frontend.components.file-sync :as file-sync]
|
|
|
[frontend.components.page :as component-page]
|
|
|
[frontend.components.plugins :as plugin]
|
|
|
[frontend.components.property.dialog :as property-dialog]
|
|
|
@@ -20,6 +23,7 @@
|
|
|
[frontend.fs.capacitor-fs :as capacitor-fs]
|
|
|
[frontend.fs.nfs :as nfs]
|
|
|
[frontend.fs.sync :as sync]
|
|
|
+ [frontend.handler.db-based.rtc :as rtc-handler]
|
|
|
[frontend.handler.editor :as editor-handler]
|
|
|
[frontend.handler.events :as events]
|
|
|
[frontend.handler.file-based.nfs :as nfs-handler]
|
|
|
@@ -27,8 +31,11 @@
|
|
|
[frontend.handler.notification :as notification]
|
|
|
[frontend.handler.page :as page-handler]
|
|
|
[frontend.handler.plugin :as plugin-handler]
|
|
|
+ [frontend.handler.repo :as repo-handler]
|
|
|
[frontend.handler.route :as route-handler]
|
|
|
+ [frontend.handler.user :as user-handler]
|
|
|
[frontend.mobile.util :as mobile-util]
|
|
|
+ [frontend.modules.instrumentation.sentry :as sentry-event]
|
|
|
[frontend.state :as state]
|
|
|
[frontend.ui :as ui]
|
|
|
[frontend.util :as util]
|
|
|
@@ -352,3 +359,35 @@
|
|
|
(merge {:close-btn? false
|
|
|
:center? true
|
|
|
:close-backdrop? false} opts)))
|
|
|
+
|
|
|
+(defn- enable-beta-features!
|
|
|
+ []
|
|
|
+ (when-not (false? (state/enable-sync?)) ; user turns it off
|
|
|
+ (file-sync-handler/set-sync-enabled! true)))
|
|
|
+
|
|
|
+;; TODO: separate rtc and file-based implementation
|
|
|
+(defmethod events/handle :user/fetch-info-and-graphs [[_]]
|
|
|
+ (state/set-state! [:ui/loading? :login] false)
|
|
|
+ (async/go
|
|
|
+ (let [result (async/<! (sync/<user-info sync/remoteapi))]
|
|
|
+ (cond
|
|
|
+ (instance? ExceptionInfo result)
|
|
|
+ nil
|
|
|
+ (map? result)
|
|
|
+ (do
|
|
|
+ (state/set-user-info! result)
|
|
|
+ (when-let [uid (user-handler/user-uuid)]
|
|
|
+ (sentry-event/set-user! uid))
|
|
|
+ (let [status (if (user-handler/alpha-or-beta-user?) :welcome :unavailable)]
|
|
|
+ (when (and (= status :welcome) (user-handler/logged-in?))
|
|
|
+ (enable-beta-features!)
|
|
|
+ (async/<! (p->c (rtc-handler/<get-remote-graphs)))
|
|
|
+ (async/<! (file-sync-handler/load-session-graphs))
|
|
|
+ (p/let [repos (repo-handler/refresh-repos!)]
|
|
|
+ (when-let [repo (state/get-current-repo)]
|
|
|
+ (when (some #(and (= (:url %) repo)
|
|
|
+ (vector? (:sync-meta %))
|
|
|
+ (util/uuid-string? (first (:sync-meta %)))
|
|
|
+ (util/uuid-string? (second (:sync-meta %)))) repos)
|
|
|
+ (sync/<sync-start)))))
|
|
|
+ (file-sync/maybe-onboarding-show status)))))))
|