Move mobile startup to mobile.core/init to not have warning on every shadow reload

It is also the more appropriate place to have init code. Side effecting
on a namespace require should be avoided as much as possible

Cherry-pick #4482
pull/4518/head
Gabriel Horner 2022-03-07 14:41:51 -05:00 committed by Andelf
parent 5dd0234b9a
commit d8bc074be1
2 changed files with 18 additions and 14 deletions

View File

@ -16,11 +16,6 @@
[]
(.ensureDocuments mobile-util/ios-file-container)))
(when (mobile-util/is-native-platform?)
(.addListener mobile-util/fs-watcher "watcher"
(fn [event]
(state/pub-event! [:file-watcher/changed event]))))
(defn check-permission-android []
(p/let [permission (.checkPermissions Filesystem)
permission (-> permission

View File

@ -15,6 +15,17 @@
[frontend.util :as util]
[frontend.config :as config]))
(defn- ios-init
[]
(let [path (fs/iOS-ensure-documents!)]
(println "iOS container path: " path))
;; Keyboard watcher
;; (.addListener Keyboard "keyboardWillShow"
;; #(state/pub-event! [:mobile/keyboard-will-show]))
(.addListener Keyboard "keyboardDidShow"
#(state/pub-event! [:mobile/keyboard-did-show])))
(defn init!
[]
;; patch back navigation
@ -38,17 +49,15 @@
(not (string/includes? href "#/")))
(.exitApp App)
(js/window.history.back))))))
(when (mobile-util/native-ios?)
(let [path (fs/iOS-ensure-documents!)]
(println "iOS container path: " path))
;; Keyboard watcher
;; (.addListener Keyboard "keyboardWillShow"
;; #(state/pub-event! [:mobile/keyboard-will-show]))
(.addListener Keyboard "keyboardDidShow"
#(state/pub-event! [:mobile/keyboard-did-show])))
(when (mobile-util/native-ios?)
(ios-init))
(when (mobile-util/is-native-platform?)
(.addListener mobile-util/fs-watcher "watcher"
(fn [event]
(state/pub-event! [:file-watcher/changed event])))
(.addEventListener js/window "statusTap"
#(util/scroll-to-top true))
@ -60,7 +69,7 @@
(if is-active?
(p/do!
(when (mobile-util/native-ios?)
(mobile-util/sync-icloud-repo repo-dir))
(mobile-util/sync-icloud-repo repo-dir))
(nfs-handler/refresh! repo repo/refresh-cb)
(notification/show! "Notes updated!" :success true))
(editor-handler/save-current-block!))))))))