events.cljs 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. (ns frontend.handler.events
  2. "System-component-like ns that defines named events and listens on a
  3. core.async channel to handle them. Any part of the system can dispatch
  4. one of these events using state/pub-event!"
  5. (:refer-clojure :exclude [run!])
  6. (:require ["@capacitor/filesystem" :refer [Directory Filesystem]]
  7. ["@sentry/react" :as Sentry]
  8. [cljs-bean.core :as bean]
  9. [clojure.core.async :as async]
  10. [clojure.core.async.interop :refer [p->c]]
  11. [clojure.string :as string]
  12. [frontend.commands :as commands]
  13. [frontend.components.cmdk.core :as cmdk]
  14. [frontend.components.block :as block]
  15. [frontend.components.settings :as settings]
  16. [frontend.components.diff :as diff]
  17. [frontend.components.encryption :as encryption]
  18. [frontend.components.file-sync :as file-sync]
  19. [frontend.components.git :as git-component]
  20. [frontend.components.plugins :as plugin]
  21. [frontend.components.shell :as shell]
  22. [frontend.components.whiteboard :as whiteboard]
  23. [frontend.components.user.login :as login]
  24. [frontend.components.repo :as repo]
  25. [frontend.components.property.dialog :as property-dialog]
  26. [frontend.config :as config]
  27. [frontend.context.i18n :refer [t]]
  28. [logseq.shui.ui :as shui]
  29. [frontend.db :as db]
  30. [frontend.db.conn :as conn]
  31. [frontend.db.model :as db-model]
  32. [frontend.db.persist :as db-persist]
  33. [frontend.db.transact :as db-transact]
  34. [frontend.extensions.srs :as srs]
  35. [frontend.fs :as fs]
  36. [frontend.fs.capacitor-fs :as capacitor-fs]
  37. [frontend.fs.nfs :as nfs]
  38. [frontend.fs.sync :as sync]
  39. [frontend.fs.watcher-handler :as fs-watcher]
  40. [frontend.handler.editor :as editor-handler]
  41. [frontend.handler.file :as file-handler]
  42. [frontend.handler.file-sync :as file-sync-handler]
  43. [frontend.handler.notification :as notification]
  44. [frontend.handler.page :as page-handler]
  45. [frontend.handler.common.page :as page-common-handler]
  46. [frontend.handler.plugin :as plugin-handler]
  47. [frontend.handler.repo :as repo-handler]
  48. [frontend.handler.repo-config :as repo-config-handler]
  49. [frontend.handler.route :as route-handler]
  50. [frontend.handler.search :as search-handler]
  51. [frontend.handler.shell :as shell-handler]
  52. [frontend.handler.ui :as ui-handler]
  53. [frontend.handler.user :as user-handler]
  54. [frontend.handler.file-based.nfs :as nfs-handler]
  55. [frontend.handler.code :as code-handler]
  56. [frontend.handler.db-based.rtc :as rtc-handler]
  57. [frontend.handler.graph :as graph-handler]
  58. [frontend.handler.db-based.property :as db-property-handler]
  59. [frontend.mobile.core :as mobile]
  60. [frontend.mobile.graph-picker :as graph-picker]
  61. [frontend.mobile.util :as mobile-util]
  62. [frontend.modules.instrumentation.posthog :as posthog]
  63. [frontend.modules.instrumentation.sentry :as sentry-event]
  64. [frontend.modules.shortcut.core :as st]
  65. [frontend.quick-capture :as quick-capture]
  66. [frontend.search :as search]
  67. [frontend.state :as state]
  68. [frontend.ui :as ui]
  69. [frontend.util :as util]
  70. [frontend.util.persist-var :as persist-var]
  71. [goog.dom :as gdom]
  72. [logseq.common.config :as common-config]
  73. [logseq.common.util :as common-util]
  74. [promesa.core :as p]
  75. [lambdaisland.glogi :as log]
  76. [rum.core :as rum]
  77. [frontend.rum :as r]
  78. [frontend.persist-db.browser :as db-browser]
  79. [frontend.modules.outliner.pipeline :as pipeline]
  80. [frontend.date :as date]
  81. [logseq.db :as ldb]
  82. [frontend.persist-db :as persist-db]
  83. [frontend.handler.export :as export]
  84. [frontend.extensions.fsrs :as fsrs]))
  85. ;; TODO: should we move all events here?
  86. (defmulti handle first)
  87. (defn file-sync-restart! []
  88. (async/go (async/<! (p->c (persist-var/load-vars)))
  89. (async/<! (sync/<sync-stop))
  90. (some-> (sync/<sync-start) async/<!)))
  91. (defn- file-sync-stop! []
  92. (async/go (async/<! (p->c (persist-var/load-vars)))
  93. (async/<! (sync/<sync-stop))))
  94. (defn- enable-beta-features!
  95. []
  96. (when-not (false? (state/enable-sync?)) ; user turns it off
  97. (file-sync-handler/set-sync-enabled! true)))
  98. (defmethod handle :user/fetch-info-and-graphs [[_]]
  99. (state/set-state! [:ui/loading? :login] false)
  100. (async/go
  101. (let [result (async/<! (sync/<user-info sync/remoteapi))]
  102. (cond
  103. (instance? ExceptionInfo result)
  104. nil
  105. (map? result)
  106. (do
  107. (state/set-user-info! result)
  108. (when-let [uid (user-handler/user-uuid)]
  109. (sentry-event/set-user! uid))
  110. (let [status (if (user-handler/alpha-or-beta-user?) :welcome :unavailable)]
  111. (when (and (= status :welcome) (user-handler/logged-in?))
  112. (enable-beta-features!)
  113. (async/<! (rtc-handler/<get-remote-graphs))
  114. (async/<! (file-sync-handler/load-session-graphs))
  115. (p/let [repos (repo-handler/refresh-repos!)]
  116. (when-let [repo (state/get-current-repo)]
  117. (when (some #(and (= (:url %) repo)
  118. (vector? (:sync-meta %))
  119. (util/uuid-string? (first (:sync-meta %)))
  120. (util/uuid-string? (second (:sync-meta %)))) repos)
  121. (sync/<sync-start)))))
  122. (ui-handler/re-render-root!)
  123. (file-sync/maybe-onboarding-show status)))))))
  124. (defmethod handle :user/logout [[_]]
  125. (file-sync-handler/reset-session-graphs)
  126. (sync/remove-all-pwd!)
  127. (file-sync-handler/reset-user-state!)
  128. (login/sign-out!))
  129. (defmethod handle :user/login [[_ host-ui?]]
  130. (if (or host-ui? (not util/electron?))
  131. (js/window.open config/LOGIN-URL)
  132. (if (mobile-util/native-platform?)
  133. (route-handler/redirect! {:to :user-login})
  134. (login/open-login-modal!))))
  135. (defmethod handle :graph/added [[_ repo {:keys [empty-graph?]}]]
  136. (search-handler/rebuild-indices!)
  137. (plugin-handler/hook-plugin-app :graph-after-indexed {:repo repo :empty-graph? empty-graph?})
  138. (route-handler/redirect-to-home!)
  139. (when-let [dir-name (and (not (config/db-based-graph? repo)) (config/get-repo-dir repo))]
  140. (fs/watch-dir! dir-name))
  141. (file-sync-restart!))
  142. (defmethod handle :init/commands [_]
  143. (page-handler/init-commands!))
  144. (defmethod handle :graph/unlinked [repo current-repo]
  145. (when (= (:url repo) current-repo)
  146. (file-sync-restart!)))
  147. ;; FIXME(andelf): awful multi-arty function.
  148. ;; Should use a `-impl` function instead of the awful `skip-ios-check?` param with nested callback.
  149. (defn- graph-switch
  150. ([graph]
  151. (graph-switch graph false))
  152. ([graph skip-ios-check?]
  153. (let [db-based? (config/db-based-graph? graph)]
  154. (if (and (mobile-util/native-ios?) (not skip-ios-check?))
  155. (state/pub-event! [:validate-appId graph-switch graph])
  156. (do
  157. (state/set-current-repo! graph)
  158. (page-handler/init-commands!)
  159. ;; load config
  160. (repo-config-handler/restore-repo-config! graph)
  161. (when-not (= :draw (state/get-current-route))
  162. (route-handler/redirect-to-home!))
  163. (state/pub-event! [:graph/ready graph])
  164. (if db-based?
  165. (rtc-handler/<rtc-start! graph)
  166. (file-sync-restart!))
  167. (when-let [dir-name (and (not db-based?) (config/get-repo-dir graph))]
  168. (fs/watch-dir! dir-name))
  169. (graph-handler/settle-metadata-to-local! {:last-seen-at (js/Date.now)}))))))
  170. ;; Parameters for the `persist-db` function, to show the notification messages
  171. (defn- graph-switch-on-persisted
  172. "graph: the target graph to switch to"
  173. [graph opts]
  174. (p/do!
  175. (repo-handler/restore-and-setup-repo! graph)
  176. (graph-switch graph)
  177. (state/set-state! :sync-graph/init? false)
  178. (when (:rtc-download? opts)
  179. (and (search-handler/rebuild-indices!) true)
  180. (repo-handler/refresh-repos!))))
  181. (defmethod handle :graph/switch [[_ graph opts]]
  182. (export/cancel-db-backup!)
  183. (persist-db/export-current-graph!)
  184. (state/set-state! :db/async-query-loading #{})
  185. (state/set-state! :db/async-queries {})
  186. (st/refresh!)
  187. (reset! r/*key->atom {})
  188. (let [^js sqlite @db-browser/*worker]
  189. (p/let [writes-finished? (when sqlite (.file-writes-finished? sqlite (state/get-current-repo)))
  190. request-finished? (db-transact/request-finished?)]
  191. (if (not writes-finished?) ; TODO: test (:sync-graph/init? @state/state)
  192. (do
  193. (log/info :graph/switch (cond->
  194. {:request-finished? request-finished?
  195. :file-writes-finished? writes-finished?}
  196. (false? request-finished?)
  197. (assoc :unfinished-requests? @db-transact/*unfinished-request-ids)))
  198. (notification/show!
  199. "Please wait seconds until all changes are saved for the current graph."
  200. :warning))
  201. (graph-switch-on-persisted graph opts)))))
  202. (defmethod handle :graph/pull-down-remote-graph [[_ graph dir-name]]
  203. (if (mobile-util/native-ios?)
  204. (when-let [graph-name (or dir-name (:GraphName graph))]
  205. (let [graph-name (util/safe-sanitize-file-name graph-name)]
  206. (if (string/blank? graph-name)
  207. (notification/show! "Illegal graph folder name.")
  208. ;; Create graph directory under Logseq document folder (local)
  209. (when-let [root (state/get-local-container-root-url)]
  210. (let [graph-path (graph-picker/validate-graph-dirname root graph-name)]
  211. (->
  212. (p/let [exists? (fs/dir-exists? graph-path)]
  213. (let [overwrite? (if exists?
  214. (js/confirm (str "There's already a directory with the name \"" graph-name "\", do you want to overwrite it? Make sure to backup it first if you're not sure about it."))
  215. true)]
  216. (if overwrite?
  217. (p/let [_ (fs/mkdir-if-not-exists graph-path)]
  218. (nfs-handler/ls-dir-files-with-path!
  219. graph-path
  220. {:ok-handler (fn []
  221. (file-sync-handler/init-remote-graph graph-path graph)
  222. (js/setTimeout (fn [] (repo-handler/refresh-repos!)) 200))}))
  223. (let [graph-name (-> (js/prompt "Please specify a new directory name to download the graph:")
  224. str
  225. string/trim)]
  226. (when-not (string/blank? graph-name)
  227. (state/pub-event! [:graph/pull-down-remote-graph graph graph-name]))))))
  228. (p/catch (fn [^js e]
  229. (notification/show! (str e) :error)
  230. (js/console.error e)))))))))
  231. (shui/dialog-open!
  232. (file-sync/pick-dest-to-sync-panel graph))))
  233. (defmethod handle :graph/pick-page-histories [[_ graph-uuid page-name]]
  234. (shui/dialog-open!
  235. (file-sync/pick-page-histories-panel graph-uuid page-name)
  236. {:id :page-histories :label "modal-page-histories"}))
  237. (defmethod handle :graph/open-new-window [[_ev target-repo]]
  238. (p/let [current-repo (state/get-current-repo)]
  239. (ui-handler/open-new-window-or-tab! current-repo target-repo)))
  240. (defmethod handle :graph/migrated [[_ _repo]]
  241. (js/alert "Graph migrated."))
  242. (defn get-local-repo
  243. []
  244. (when-let [repo (state/get-current-repo)]
  245. (when (config/local-file-based-graph? repo)
  246. repo)))
  247. (defn ask-permission
  248. [repo]
  249. (when
  250. (and (not (util/electron?))
  251. (not (mobile-util/native-platform?)))
  252. (fn [{:keys [close]}]
  253. [:div
  254. ;; TODO: fn translation with args
  255. [:p
  256. "Grant native filesystem permission for directory: "
  257. [:b (config/get-local-dir repo)]]
  258. (ui/button
  259. (t :settings-permission/start-granting)
  260. :class "ui__modal-enter"
  261. :on-click (fn []
  262. (nfs/check-directory-permission! repo)
  263. (close)))])))
  264. (defmethod handle :modal/nfs-ask-permission []
  265. (when-let [repo (get-local-repo)]
  266. (some-> (ask-permission repo)
  267. (shui/dialog-open! {:align :top}))))
  268. (defmethod handle :modal/show-cards [[_ cards-id]]
  269. (let [db-based? (config/db-based-graph? (state/get-current-repo))]
  270. (shui/dialog-open!
  271. (if db-based? (fn [] (fsrs/cards-view cards-id)) srs/global-cards)
  272. {:id :srs
  273. :label "flashcards__cp"})))
  274. (defmethod handle :modal/show-instruction [_]
  275. (shui/dialog-open!
  276. capacitor-fs/instruction
  277. {:id :instruction
  278. :label "instruction__cp"}))
  279. (defmethod handle :modal/show-themes-modal [[_ classic?]]
  280. (if classic?
  281. (plugin/open-select-theme!)
  282. (route-handler/go-to-search! :themes)))
  283. (defmethod handle :modal/toggle-appearance-modal [_]
  284. (let [label "customize-appearance"]
  285. (if (shui/dialog-get label)
  286. (shui/dialog-close! label)
  287. (shui/dialog-open!
  288. #(settings/modal-appearance-inner)
  289. {:id label
  290. :overlay-props {:label label}
  291. :label label}))))
  292. (defmethod handle :modal/set-git-username-and-email [[_ _content]]
  293. (shui/dialog-open! git-component/set-git-username-and-email))
  294. (defmethod handle :page/create [[_ page-name opts]]
  295. (if (= page-name (date/today))
  296. (page-handler/create-today-journal!)
  297. (page-handler/<create! page-name opts)))
  298. (defmethod handle :page/deleted [[_ repo page-name file-path tx-meta]]
  299. (page-common-handler/after-page-deleted! repo page-name file-path tx-meta))
  300. (defmethod handle :page/renamed [[_ repo data]]
  301. (page-common-handler/after-page-renamed! repo data))
  302. (defmethod handle :page/create-today-journal [[_ _repo]]
  303. (p/let [_ (page-handler/create-today-journal!)]
  304. (ui-handler/re-render-root!)))
  305. (defmethod handle :file/not-matched-from-disk [[_ path disk-content db-content]]
  306. (when-let [repo (state/get-current-repo)]
  307. (shui/dialog-open!
  308. #(diff/local-file repo path disk-content db-content)
  309. {:label "diff__cp"})))
  310. (defmethod handle :modal/display-file-version-selector [[_ versions path get-content]]
  311. (shui/dialog-open!
  312. #(git-component/file-version-selector versions path get-content)))
  313. (defmethod handle :graph/sync-context []
  314. (let [context {:dev? config/dev?
  315. :node-test? util/node-test?
  316. :validate-db-options (:dev/validate-db-options (state/get-config))
  317. :importing? (:graph/importing @state/state)
  318. :date-formatter (state/get-date-formatter)
  319. :journal-file-name-format (or (state/get-journal-file-name-format)
  320. date/default-journal-filename-formatter)
  321. :export-bullet-indentation (state/get-export-bullet-indentation)
  322. :preferred-format (state/get-preferred-format)
  323. :journals-directory (config/get-journals-directory)
  324. :whiteboards-directory (config/get-whiteboards-directory)
  325. :pages-directory (config/get-pages-directory)}
  326. worker ^Object @state/*db-worker]
  327. (when worker (.set-context worker (ldb/write-transit-str context)))))
  328. ;; Hook on a graph is ready to be shown to the user.
  329. ;; It's different from :graph/restored, as :graph/restored is for window reloaded
  330. ;; FIXME: config may not be loaded when the graph is ready.
  331. (defmethod handle :graph/ready
  332. [[_ repo]]
  333. (when (config/local-file-based-graph? repo)
  334. (p/let [dir (config/get-repo-dir repo)
  335. dir-exists? (fs/dir-exists? dir)]
  336. (when (and (not dir-exists?)
  337. (not util/nfs?))
  338. (state/pub-event! [:graph/dir-gone dir]))))
  339. (let [db-based? (config/db-based-graph? repo)]
  340. (p/do!
  341. (state/pub-event! [:graph/sync-context])
  342. ;; re-render-root is async and delegated to rum, so we need to wait for main ui to refresh
  343. (when (mobile-util/native-ios?)
  344. (js/setTimeout #(mobile/mobile-postinit) 1000))
  345. ;; FIXME: an ugly implementation for redirecting to page on new window is restored
  346. (repo-handler/graph-ready! repo)
  347. (if db-based?
  348. (export/auto-db-backup! repo {:backup-now? true})
  349. (fs-watcher/load-graph-files! repo)))))
  350. (defmethod handle :notification/show [[_ {:keys [content status clear?]}]]
  351. (notification/show! content status clear?))
  352. (defmethod handle :command/run [_]
  353. (when (util/electron?)
  354. (shui/dialog-open! shell/shell)))
  355. (defmethod handle :go/search [_]
  356. (state/set-modal! cmdk/cmdk-modal
  357. {:fullscreen? true
  358. :close-btn? false
  359. :panel? false
  360. :label "ls-modal-search"}))
  361. (defmethod handle :go/plugins [_]
  362. (plugin/open-plugins-modal!))
  363. (defmethod handle :go/plugins-waiting-lists [_]
  364. (plugin/open-waiting-updates-modal!))
  365. (defmethod handle :go/plugins-from-file [[_ plugins]]
  366. (plugin/open-plugins-from-file-modal! plugins))
  367. (defmethod handle :go/plugins-settings [[_ pid nav? title]]
  368. (when pid
  369. (state/set-state! :plugin/focused-settings pid)
  370. (state/set-state! :plugin/navs-settings? (not (false? nav?)))
  371. (plugin/open-focused-settings-modal! title)))
  372. (defmethod handle :go/proxy-settings [[_ agent-opts]]
  373. (shui/dialog-open!
  374. (plugin/user-proxy-settings-panel agent-opts)
  375. {:id :https-proxy-panel :center? true :class "lg:max-w-2xl"}))
  376. (defmethod handle :redirect-to-home [_]
  377. (page-handler/create-today-journal!))
  378. (defmethod handle :instrument [[_ {:keys [type payload] :as opts}]]
  379. (when-not (empty? (dissoc opts :type :payload))
  380. (js/console.error "instrument data-map should only contains [:type :payload]"))
  381. (posthog/capture type payload))
  382. (defmethod handle :capture-error [[_ {:keys [error payload]}]]
  383. (let [[user-uuid graph-uuid tx-id] @sync/graphs-txid
  384. payload (assoc payload
  385. :user-id user-uuid
  386. :graph-id graph-uuid
  387. :tx-id tx-id
  388. :db-based (config/db-based-graph? (state/get-current-repo)))]
  389. (Sentry/captureException error
  390. (bean/->js {:tags payload}))))
  391. (defmethod handle :exec-plugin-cmd [[_ {:keys [pid cmd action]}]]
  392. (commands/exec-plugin-simple-command! pid cmd action))
  393. (defmethod handle :shortcut-handler-refreshed [[_]]
  394. (when-not @st/*pending-inited?
  395. (reset! st/*pending-inited? true)
  396. (st/consume-pending-shortcuts!)))
  397. (defmethod handle :mobile/keyboard-will-show [[_ keyboard-height]]
  398. (let [main-node (util/app-scroll-container-node)]
  399. (state/set-state! :mobile/show-tabbar? false)
  400. (state/set-state! :mobile/show-toolbar? true)
  401. (state/set-state! :mobile/show-action-bar? false)
  402. (when (= (state/sub :editor/record-status) "RECORDING")
  403. (state/set-state! :mobile/show-recording-bar? true))
  404. (when (mobile-util/native-ios?)
  405. (reset! util/keyboard-height keyboard-height)
  406. (set! (.. main-node -style -marginBottom) (str keyboard-height "px"))
  407. (when-let [^js html (js/document.querySelector ":root")]
  408. (.setProperty (.-style html) "--ls-native-kb-height" (str keyboard-height "px"))
  409. (.add (.-classList html) "has-mobile-keyboard"))
  410. (when-let [left-sidebar-node (gdom/getElement "left-sidebar")]
  411. (set! (.. left-sidebar-node -style -bottom) (str keyboard-height "px")))
  412. (when-let [right-sidebar-node (gdom/getElementByClass "sidebar-item-list")]
  413. (set! (.. right-sidebar-node -style -paddingBottom) (str (+ 150 keyboard-height) "px")))
  414. (when-let [card-preview-el (js/document.querySelector ".cards-review")]
  415. (set! (.. card-preview-el -style -marginBottom) (str keyboard-height "px")))
  416. (when-let [card-preview-el (js/document.querySelector ".encryption-password")]
  417. (set! (.. card-preview-el -style -marginBottom) (str keyboard-height "px")))
  418. (js/setTimeout (fn []
  419. (when-let [toolbar (.querySelector main-node "#mobile-editor-toolbar")]
  420. (set! (.. toolbar -style -bottom) (str keyboard-height "px"))))
  421. 100))))
  422. (defmethod handle :mobile/keyboard-will-hide [[_]]
  423. (let [main-node (util/app-scroll-container-node)]
  424. (state/set-state! :mobile/show-toolbar? false)
  425. (state/set-state! :mobile/show-tabbar? true)
  426. (when (= (state/sub :editor/record-status) "RECORDING")
  427. (state/set-state! :mobile/show-recording-bar? false))
  428. (when (mobile-util/native-ios?)
  429. (when-let [^js html (js/document.querySelector ":root")]
  430. (.removeProperty (.-style html) "--ls-native-kb-height")
  431. (.remove (.-classList html) "has-mobile-keyboard"))
  432. (when-let [card-preview-el (js/document.querySelector ".cards-review")]
  433. (set! (.. card-preview-el -style -marginBottom) "0px"))
  434. (when-let [card-preview-el (js/document.querySelector ".encryption-password")]
  435. (set! (.. card-preview-el -style -marginBottom) "0px"))
  436. (set! (.. main-node -style -marginBottom) "0px")
  437. (when-let [left-sidebar-node (gdom/getElement "left-sidebar")]
  438. (set! (.. left-sidebar-node -style -bottom) "0px"))
  439. (when-let [right-sidebar-node (gdom/getElementByClass "sidebar-item-list")]
  440. (set! (.. right-sidebar-node -style -paddingBottom) "150px"))
  441. (when-let [toolbar (.querySelector main-node "#mobile-editor-toolbar")]
  442. (set! (.. toolbar -style -bottom) 0)))))
  443. (defn- get-ios-app-id
  444. [repo-url]
  445. (when repo-url
  446. (let [app-id (-> (first (string/split repo-url "/Documents"))
  447. (string/split "/")
  448. last)]
  449. app-id)))
  450. (defmethod handle :validate-appId [[_ graph-switch-f graph]]
  451. (when-let [deprecated-repo (or graph (state/get-current-repo))]
  452. (if (mobile-util/in-iCloud-container-path? deprecated-repo)
  453. ;; Installation is not changed for iCloud
  454. (when graph-switch-f
  455. (graph-switch-f graph true)
  456. (state/pub-event! [:graph/ready (state/get-current-repo)]))
  457. ;; Installation is changed for App Documents directory
  458. (p/let [deprecated-app-id (get-ios-app-id deprecated-repo)
  459. current-document-url (.getUri Filesystem #js {:path ""
  460. :directory (.-Documents Directory)})
  461. current-app-id (-> (js->clj current-document-url :keywordize-keys true)
  462. get-ios-app-id)]
  463. (if (= deprecated-app-id current-app-id)
  464. (when graph-switch-f (graph-switch-f graph true))
  465. (do
  466. (notification/show! [:div "Migrating from previous App installation..."]
  467. :warning
  468. true)
  469. (prn ::migrate-app-id :from deprecated-app-id :to current-app-id)
  470. (file-sync-stop!)
  471. (.unwatch mobile-util/fs-watcher)
  472. (let [current-repo (string/replace deprecated-repo deprecated-app-id current-app-id)
  473. current-repo-dir (config/get-repo-dir current-repo)]
  474. (try
  475. ;; replace app-id part of repo url
  476. (reset! conn/conns
  477. (update-keys @conn/conns
  478. (fn [key]
  479. (if (string/includes? key deprecated-app-id)
  480. (string/replace key deprecated-app-id current-app-id)
  481. key))))
  482. (db-persist/rename-graph! deprecated-repo current-repo)
  483. (search/remove-db! deprecated-repo)
  484. (state/add-repo! {:url current-repo :nfs? true})
  485. (state/delete-repo! {:url deprecated-repo})
  486. (catch :default e
  487. (js/console.error e)))
  488. (state/set-current-repo! current-repo)
  489. (repo-config-handler/restore-repo-config! current-repo)
  490. (when graph-switch-f (graph-switch-f current-repo true))
  491. (.watch mobile-util/fs-watcher #js {:path current-repo-dir})
  492. (file-sync-restart!))))
  493. (state/pub-event! [:graph/ready (state/get-current-repo)])))))
  494. (defmethod handle :plugin/consume-updates [[_ id prev-pending? updated?]]
  495. (let [downloading? (:plugin/updates-downloading? @state/state)
  496. auto-checking? (plugin-handler/get-auto-checking?)]
  497. (when-let [coming (and (not downloading?)
  498. (get-in @state/state [:plugin/updates-coming id]))]
  499. (let [error-code (:error-code coming)
  500. error-code (if (= error-code (str :no-new-version)) nil error-code)
  501. title (:title coming)]
  502. (when (and prev-pending? (not auto-checking?))
  503. (if-not error-code
  504. (plugin/set-updates-sub-content! (str title "...") 0)
  505. (notification/show!
  506. (str "[Checked]<" title "> " error-code) :error)))))
  507. (if (and updated? downloading?)
  508. ;; try to start consume downloading item
  509. (if-let [next-coming (state/get-next-selected-coming-update)]
  510. (plugin-handler/check-or-update-marketplace-plugin!
  511. (assoc next-coming :only-check false :error-code nil)
  512. (fn [^js e] (js/console.error "[Download Err]" next-coming e)))
  513. (plugin-handler/close-updates-downloading))
  514. ;; try to start consume pending item
  515. (if-let [next-pending (second (first (:plugin/updates-pending @state/state)))]
  516. (do
  517. (println "Updates: take next pending - " (:id next-pending))
  518. (js/setTimeout
  519. #(plugin-handler/check-or-update-marketplace-plugin!
  520. (assoc next-pending :only-check true :auto-check auto-checking? :error-code nil)
  521. (fn [^js e]
  522. (notification/show! (.toString e) :error)
  523. (js/console.error "[Check Err]" next-pending e))) 500))
  524. ;; try to open waiting updates list
  525. (do (when (and prev-pending? (not auto-checking?)
  526. (seq (state/all-available-coming-updates)))
  527. (plugin/open-waiting-updates-modal!))
  528. (plugin-handler/set-auto-checking! false))))))
  529. (defmethod handle :plugin/hook-db-tx [[_ {:keys [blocks tx-data] :as payload}]]
  530. (when-let [payload (and (seq blocks)
  531. (merge payload {:tx-data (map #(into [] %) tx-data)}))]
  532. (plugin-handler/hook-plugin-db :changed payload)
  533. (plugin-handler/hook-plugin-block-changes payload)))
  534. (defmethod handle :plugin/loader-perf-tip [[_ {:keys [^js o _s _e]}]]
  535. (when-let [opts (.-options o)]
  536. (notification/show!
  537. (plugin/perf-tip-content (.-id o) (.-name opts) (.-url opts))
  538. :warning false (.-id o))))
  539. (defmethod handle :mobile-file-watcher/changed [[_ ^js event]]
  540. (let [type (.-event event)
  541. payload (js->clj event :keywordize-keys true)]
  542. (fs-watcher/handle-changed! type payload)
  543. (when (file-sync-handler/enable-sync?)
  544. (sync/file-watch-handler type payload))))
  545. (defmethod handle :rebuild-slash-commands-list [[_]]
  546. (page-handler/rebuild-slash-commands-list!))
  547. (defmethod handle :shortcut/refresh [[_]]
  548. (st/refresh!))
  549. (defn- refresh-cb []
  550. (page-handler/create-today-journal!)
  551. (file-sync-restart!))
  552. (defmethod handle :graph/ask-for-re-fresh [_]
  553. (shui/dialog-open!
  554. [:div {:style {:max-width 700}}
  555. [:p (t :sync-from-local-changes-detected)]
  556. [:div.flex.justify-end
  557. (ui/button
  558. (t :yes)
  559. :autoFocus "on"
  560. :class "ui__modal-enter"
  561. :on-click (fn []
  562. (shui/dialog-close!)
  563. (nfs-handler/refresh! (state/get-current-repo) refresh-cb)))]]))
  564. (defmethod handle :sync/create-remote-graph [[_ current-repo]]
  565. (let [graph-name (js/decodeURI (util/node-path.basename current-repo))]
  566. (async/go
  567. (async/<! (sync/<sync-stop))
  568. (state/set-state! [:ui/loading? :graph/create-remote?] true)
  569. (when-let [GraphUUID (get (async/<! (file-sync-handler/create-graph graph-name)) 2)]
  570. (async/<! (sync/<sync-start))
  571. (state/set-state! [:ui/loading? :graph/create-remote?] false)
  572. ;; update existing repo
  573. (state/set-repos! (map (fn [r]
  574. (if (= (:url r) current-repo)
  575. (assoc r
  576. :GraphUUID GraphUUID
  577. :GraphName graph-name
  578. :remote? true)
  579. r))
  580. (state/get-repos)))))))
  581. (defmethod handle :modal/remote-encryption-input-pw-dialog [[_ repo-url remote-graph-info type opts]]
  582. (shui/dialog-open!
  583. (encryption/input-password
  584. repo-url nil (merge
  585. (assoc remote-graph-info
  586. :type (or type :create-pwd-remote)
  587. :repo repo-url)
  588. opts))
  589. {:center? true :close-btn? false :close-backdrop? false}))
  590. (defmethod handle :journal/insert-template [[_ page-name]]
  591. (let [page-name (util/page-name-sanity-lc page-name)]
  592. (when-let [page (db/get-page page-name)]
  593. (when (db/page-empty? (state/get-current-repo) page-name)
  594. (when-let [template (state/get-default-journal-template)]
  595. (editor-handler/insert-template!
  596. nil
  597. template
  598. {:target page}))))))
  599. (defmethod handle :editor/set-org-mode-heading [[_ block heading]]
  600. (when-let [id (:block/uuid block)]
  601. (editor-handler/set-heading! id heading)))
  602. (defmethod handle :file-sync-graph/restore-file [[_ graph page-entity content]]
  603. (when (db/get-db graph)
  604. (let [file (:block/file page-entity)]
  605. (when-let [path (:file/path file)]
  606. (when (and (not= content (:file/content file))
  607. (:file/content file))
  608. (sync/add-new-version-file graph path (:file/content file)))
  609. (p/let [_ (file-handler/alter-file graph
  610. path
  611. content
  612. {:re-render-root? true
  613. :skip-compare? true})]
  614. (state/close-modal!)
  615. (route-handler/redirect! {:to :page
  616. :path-params {:name (:block/name page-entity)}}))))))
  617. (defmethod handle :whiteboard/onboarding [[_ opts]]
  618. (shui/dialog-open!
  619. (fn [{:keys [close]}] (whiteboard/onboarding-welcome close))
  620. (merge {:close-btn? false
  621. :center? true
  622. :close-backdrop? false} opts)))
  623. (defmethod handle :file-sync/onboarding-tip [[_ type opts]]
  624. (let [type (keyword type)]
  625. (when-not (config/db-based-graph? (state/get-current-repo))
  626. (shui/dialog-open!
  627. (file-sync/make-onboarding-panel type)
  628. (merge {:close-btn? false
  629. :center? true
  630. :close-backdrop? (not= type :welcome)} opts)))))
  631. (defmethod handle :file-sync/maybe-onboarding-show [[_ type]]
  632. (file-sync/maybe-onboarding-show type))
  633. (defmethod handle :file-sync/storage-exceed-limit [[_]]
  634. (notification/show! "file sync storage exceed limit" :warning false)
  635. (file-sync-stop!))
  636. (defmethod handle :file-sync/graph-count-exceed-limit [[_]]
  637. (notification/show! "file sync graph count exceed limit" :warning false)
  638. (file-sync-stop!))
  639. (defmethod handle :graph/restored [[_ graph]]
  640. (mobile/init!)
  641. (rtc-handler/<rtc-start! graph)
  642. (fsrs/update-due-cards-count)
  643. (when-not (mobile-util/native-ios?)
  644. (state/pub-event! [:graph/ready graph])))
  645. (defmethod handle :whiteboard-link [[_ shapes]]
  646. (route-handler/go-to-search! :whiteboard/link)
  647. (state/set-state! :whiteboard/linked-shapes shapes))
  648. (defmethod handle :whiteboard-go-to-link [[_ link]]
  649. (route-handler/redirect! {:to :page
  650. :path-params {:name link}}))
  651. (defmethod handle :graph/dir-gone [[_ dir]]
  652. (state/pub-event! [:notification/show
  653. {:content (str "The directory " dir " has been renamed or deleted, the editor will be disabled for this graph, you can unlink the graph.")
  654. :status :error
  655. :clear? false}])
  656. (state/update-state! :file/unlinked-dirs (fn [dirs] (conj dirs dir))))
  657. (defmethod handle :graph/dir-back [[_ repo dir]]
  658. (when (contains? (:file/unlinked-dirs @state/state) dir)
  659. (notification/clear-all!)
  660. (state/pub-event! [:notification/show
  661. {:content (str "The directory " dir " has been back, you can edit your graph now.")
  662. :status :success
  663. :clear? true}])
  664. (state/update-state! :file/unlinked-dirs (fn [dirs] (disj dirs dir)))
  665. (when (= dir (config/get-repo-dir repo))
  666. (fs/watch-dir! dir))))
  667. (defmethod handle :ui/notify-skipped-downloading-files [[_ paths]]
  668. (notification/show!
  669. [:div
  670. [:div.mb-4
  671. [:div.font-semibold.mb-4.text-xl "It seems that some of your filenames are in the outdated format."]
  672. [:p
  673. "The files below that have reserved characters can't be saved on this device."]
  674. [:div.overflow-y-auto.max-h-96
  675. [:ol.my-2
  676. (for [path paths]
  677. [:li path])]]
  678. [:div
  679. [:p
  680. "Check " [:a {:href "https://docs.logseq.com/#/page/logseq%20file%20and%20folder%20naming%20rules"
  681. :target "_blank"}
  682. "Logseq file and folder naming rules"]
  683. " for more details."]]]]
  684. :warning
  685. false))
  686. (defmethod handle :graph/setup-a-repo [[_ opts]]
  687. (let [opts' (merge {:picked-root-fn #(state/close-modal!)
  688. :native-icloud? (not (string/blank? (state/get-icloud-container-root-url)))
  689. :logged? (user-handler/logged-in?)} opts)]
  690. (if (mobile-util/native-ios?)
  691. (shui/dialog-open!
  692. #(graph-picker/graph-picker-cp opts')
  693. {:label "graph-setup"})
  694. (page-handler/ls-dir-files! st/refresh! opts'))))
  695. (defmethod handle :graph/new-db-graph [[_ _opts]]
  696. (shui/dialog-open!
  697. repo/new-db-graph
  698. {:id :new-db-graph
  699. :title [:h2 "Create a new graph"]
  700. :style {:max-width "500px"}}))
  701. (defmethod handle :graph/save-db-to-disk [[_ _opts]]
  702. (persist-db/export-current-graph! {:succ-notification? true}))
  703. (defmethod handle :class/configure [[_ page]]
  704. (shui/dialog-open!
  705. #(block/block-container {} page)
  706. {:label "page-configure"
  707. :align :top}))
  708. (defmethod handle :file/alter [[_ repo path content]]
  709. (p/let [_ (file-handler/alter-file repo path content {:from-disk? true})]
  710. (ui-handler/re-render-root!)))
  711. (defmethod handle :ui/re-render-root [[_]]
  712. (ui-handler/re-render-root!))
  713. (rum/defcs file-id-conflict-item <
  714. (rum/local false ::resolved?)
  715. [state repo file data]
  716. (let [resolved? (::resolved? state)
  717. id (last (:assertion data))]
  718. [:li {:key file}
  719. [:div
  720. [:a {:on-click #(js/window.apis.openPath file)} file]
  721. (if @resolved?
  722. [:div.flex.flex-row.items-center
  723. (ui/icon "circle-check" {:style {:font-size 20}})
  724. [:div.ml-1 "Resolved"]]
  725. [:div
  726. [:p
  727. (str "It seems that another whiteboard file already has the ID \"" id
  728. "\". You can fix it by changing the ID in this file with another UUID.")]
  729. [:p
  730. "Or, let me"
  731. (ui/button "Fix"
  732. :on-click (fn []
  733. (let [dir (config/get-repo-dir repo)]
  734. (p/let [content (fs/read-file dir file)]
  735. (let [new-content (string/replace content (str id) (str (random-uuid)))]
  736. (p/let [_ (fs/write-file! repo
  737. dir
  738. file
  739. new-content
  740. {})]
  741. (reset! resolved? true))))))
  742. :class "inline mx-1")
  743. "it."]])]]))
  744. (defmethod handle :file/parse-and-load-error [[_ repo parse-errors]]
  745. (state/pub-event! [:notification/show
  746. {:content
  747. [:div
  748. [:h2.title "Oops. These files failed to import to your graph:"]
  749. [:ol.my-2
  750. (for [[file error] parse-errors]
  751. (let [data (ex-data error)]
  752. (cond
  753. (and (common-config/whiteboard? file)
  754. (= :transact/upsert (:error data))
  755. (uuid? (last (:assertion data))))
  756. (rum/with-key (file-id-conflict-item repo file data) file)
  757. :else
  758. (do
  759. (state/pub-event! [:capture-error {:error error
  760. :payload {:type :file/parse-and-load-error}}])
  761. [:li.my-1 {:key file}
  762. [:a {:on-click #(js/window.apis.openPath file)} file]
  763. [:p (.-message error)]]))))]
  764. [:p "Don't forget to re-index your graph when all the conflicts are resolved."]]
  765. :status :error}]))
  766. (defmethod handle :run/cli-command [[_ command content]]
  767. (when (and command (not (string/blank? content)))
  768. (shell-handler/run-cli-command-wrapper! command content)))
  769. (defmethod handle :editor/quick-capture [[_ args]]
  770. (quick-capture/quick-capture args))
  771. (defmethod handle :modal/keymap [[_]]
  772. (state/open-settings! :keymap))
  773. (defmethod handle :editor/toggle-own-number-list [[_ blocks]]
  774. (let [batch? (sequential? blocks)
  775. blocks (cond->> blocks
  776. batch?
  777. (map #(cond-> % (or (uuid? %) (string? %)) (db-model/get-block-by-uuid))))]
  778. (if (and batch? (> (count blocks) 1))
  779. (editor-handler/toggle-blocks-as-own-order-list! blocks)
  780. (when-let [block (cond-> blocks batch? (first))]
  781. (if (editor-handler/own-order-number-list? block)
  782. (editor-handler/remove-block-own-order-list-type! block)
  783. (editor-handler/make-block-as-own-order-list! block))))))
  784. (defmethod handle :editor/remove-own-number-list [[_ block]]
  785. (when (some-> block (editor-handler/own-order-number-list?))
  786. (editor-handler/remove-block-own-order-list-type! block)))
  787. (defmethod handle :editor/save-current-block [_]
  788. (editor-handler/save-current-block!))
  789. (defmethod handle :editor/save-code-editor [_]
  790. (code-handler/save-code-editor!))
  791. (defmethod handle :editor/toggle-children-number-list [[_ block]]
  792. (when-let [blocks (and block (db-model/get-block-immediate-children (state/get-current-repo) (:block/uuid block)))]
  793. (editor-handler/toggle-blocks-as-own-order-list! blocks)))
  794. (defmethod handle :editor/new-property [[_ {:keys [block target] :as opts}]]
  795. (p/do!
  796. (editor-handler/save-current-block!)
  797. (let [editing-block (state/get-edit-block)
  798. pos (state/get-edit-pos)
  799. edit-block-or-selected (if editing-block
  800. [editing-block]
  801. (seq (keep #(db/entity [:block/uuid %]) (state/get-selection-block-ids))))
  802. current-block (when-let [s (state/get-current-page)]
  803. (when (util/uuid-string? s)
  804. (db/entity [:block/uuid (uuid s)])))
  805. blocks (or (when block [block])
  806. edit-block-or-selected
  807. (when current-block [current-block]))
  808. opts' (cond-> opts
  809. editing-block
  810. (assoc :original-block editing-block
  811. :edit-original-block
  812. (fn [{:keys [editing-default-property?]}]
  813. (when editing-block
  814. (let [content (:block/title (db/entity (:db/id editing-block)))
  815. esc? (= "Escape" (state/get-ui-last-key-code))
  816. [content' pos] (cond
  817. esc?
  818. [nil pos]
  819. (and (>= (count content) pos)
  820. (>= pos 2)
  821. (= (util/nth-safe content (dec pos))
  822. (util/nth-safe content (- pos 2))
  823. ";"))
  824. [(str (common-util/safe-subs content 0 (- pos 2))
  825. (common-util/safe-subs content pos))
  826. (- pos 2)]
  827. :else
  828. [nil pos])]
  829. (when content'
  830. (if editing-default-property?
  831. (editor-handler/save-block! (state/get-current-repo) (:block/uuid editing-block) content')
  832. (editor-handler/edit-block! editing-block (or pos :max)
  833. (cond-> {}
  834. content'
  835. (assoc :custom-content content'))))))))))]
  836. (when (seq blocks)
  837. (let [target' (or target
  838. (some-> (state/get-edit-input-id)
  839. (gdom/getElement))
  840. (first (state/get-selection-blocks)))]
  841. (if target'
  842. (shui/popup-show! target'
  843. #(property-dialog/dialog blocks opts')
  844. {:align "start"
  845. :auto-focus? true})
  846. (shui/dialog-open! #(property-dialog/dialog blocks opts')
  847. {:id :property-dialog
  848. :align "start"})))))))
  849. (defmethod handle :editor/upsert-type-block [[_ {:keys [block type]}]]
  850. (p/do!
  851. (editor-handler/save-current-block!)
  852. (p/delay 16)
  853. (let [block (db/entity (:db/id block))
  854. block-type (:logseq.property.node/display-type block)
  855. block-title (:block/title block)
  856. turn-type! #(db-property-handler/set-block-property!
  857. (:block/uuid %) :logseq.property.node/display-type (keyword type))]
  858. (if (or (not (nil? block-type))
  859. (not (string/blank? block-title)))
  860. ;; insert block
  861. (let [[p _ block'] (editor-handler/insert-new-block-aux! {} block "")]
  862. (some-> p
  863. (p/then #(turn-type! block'))
  864. (p/then #(state/set-pending-type-block! block'))))
  865. (-> (turn-type! block)
  866. (p/then #(when (string/blank? block-title)
  867. (state/set-pending-type-block! block))))))))
  868. (rum/defc multi-tabs-dialog
  869. []
  870. (let [word (if (util/electron?) "window" "tab")]
  871. [:div.flex.p-4.flex-col.gap-4.h-64
  872. [:span.warning.text-lg
  873. (util/format "Logseq doesn't support multiple %ss access to the same graph yet, please close this %s or switch to another graph."
  874. word word)]
  875. [:div.text-lg
  876. [:p "Switch to another repo: "]
  877. [:div.border.rounded.bg-gray-01.overflow-hidden.w-60
  878. (repo/repos-dropdown {:on-click (fn [e]
  879. (util/stop e)
  880. (state/set-state! :error/multiple-tabs-access-opfs? false)
  881. (shui/dialog-close!))})]]]))
  882. (defmethod handle :show/multiple-tabs-error-dialog [_]
  883. (state/set-state! :error/multiple-tabs-access-opfs? true)
  884. (shui/dialog-open! multi-tabs-dialog))
  885. (defmethod handle :rtc/sync-state [[_ state]]
  886. (state/update-state! :rtc/state (fn [old] (merge old state))))
  887. (defmethod handle :rtc/log [[_ data]]
  888. (state/set-state! :rtc/log data))
  889. (defmethod handle :rtc/download-remote-graph [[_ graph-name graph-uuid]]
  890. (->
  891. (p/do!
  892. (rtc-handler/<rtc-download-graph! graph-name graph-uuid 60000))
  893. (p/catch (fn [e]
  894. (println "RTC download graph failed, error:")
  895. (js/console.error e)))))
  896. ;; db-worker -> UI
  897. (defmethod handle :db/sync-changes [[_ data]]
  898. (let [retract-datoms (filter (fn [d] (and (= :block/uuid (:a d)) (false? (:added d)))) (:tx-data data))
  899. retracted-tx-data (map (fn [d] [:db/retractEntity (:e d)]) retract-datoms)
  900. tx-data (concat (:tx-data data) retracted-tx-data)]
  901. (pipeline/invoke-hooks (assoc data :tx-data tx-data))
  902. nil))
  903. (defn run!
  904. []
  905. (let [chan (state/get-events-chan)]
  906. (async/go-loop []
  907. (let [[payload d] (async/<! chan)]
  908. (->
  909. (try
  910. (p/resolved (handle payload))
  911. (catch :default error
  912. (p/rejected error)))
  913. (p/then (fn [result]
  914. (p/resolve! d result)))
  915. (p/catch (fn [error]
  916. (let [type :handle-system-events/failed]
  917. (state/pub-event! [:capture-error {:error error
  918. :payload {:type type
  919. :payload payload}}])
  920. (p/reject! d error))))))
  921. (recur))
  922. chan))
  923. (comment
  924. (let [{:keys [deprecated-app-id current-app-id]} {:deprecated-app-id "AFDADF9A-7466-4ED8-B74F-AAAA0D4565B9", :current-app-id "7563518E-0EFD-4AD2-8577-10CFFD6E4596"}]
  925. (def deprecated-app-id deprecated-app-id)
  926. (def current-app-id current-app-id))
  927. (def deprecated-repo (state/get-current-repo))
  928. (def new-repo (string/replace deprecated-repo deprecated-app-id current-app-id))
  929. (update-file-path deprecated-repo new-repo deprecated-app-id current-app-id))