Skip to content

Commit

Permalink
remove some unnecessary iCloud sync functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
llcc committed Mar 18, 2022
1 parent 71cba1d commit 61bff0a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 44 deletions.
13 changes: 0 additions & 13 deletions ios/App/App/DownloadiCloudFiles.swift
Expand Up @@ -50,19 +50,6 @@ public class DownloadiCloudFiles: CAPPlugin, UIDocumentPickerDelegate {
call.resolve(["success": downloaded])
}

@objc func iCloudSync(_ call: CAPPluginCall) {

if let url = self.containerUrl, fileManager.fileExists(atPath: url.path) {
do {
downloaded = try self.downloadAllFilesFromCloud(at: url, ignorePattern: [".git", ".Trash", "bak", ".recycle"])
} catch {
print(error.localizedDescription)
}
}

call.resolve(["success": downloaded])
}

func appendUndownloadedFile(at url: URL){
var lastPathComponent = url.lastPathComponent
lastPathComponent.removeFirst()
Expand Down
3 changes: 0 additions & 3 deletions src/main/frontend/handler.cljs
Expand Up @@ -129,9 +129,6 @@
(js/console.error "Failed to request GitHub app tokens."))))

(watch-for-date!)
(when (and (state/get-current-repo)
(mobile-util/native-ios?))
(mobile-util/icloud-sync!))
(file-handler/watch-for-current-graph-dir!)))
(p/then (state/pub-event! [:graph/ready (state/get-current-repo)]))
(p/catch (fn [error]
Expand Down
8 changes: 2 additions & 6 deletions src/main/frontend/handler/repo.cljs
Expand Up @@ -26,7 +26,6 @@
[lambdaisland.glogi :as log]
[promesa.core :as p]
[shadow.resource :as rc]
[frontend.mobile.util :as mobile-util]
[frontend.db.persist :as db-persist]
[electron.ipc :as ipc]
[clojure.set :as set]))
Expand Down Expand Up @@ -630,12 +629,9 @@
[nfs-rebuild-index! ok-handler]
(route-handler/redirect-to-home!)
(when-let [repo (state/get-current-repo)]
(let [local? (config/local-db? repo)
repo-dir (config/get-repo-dir repo)]
(let [local? (config/local-db? repo)]
(if local?
(p/let [_ (when (mobile-util/native-ios?)
(mobile-util/sync-icloud-repo repo-dir))
_ (metadata-handler/set-pages-metadata! repo)]
(p/let [_ (metadata-handler/set-pages-metadata! repo)]
(nfs-rebuild-index! repo ok-handler))
(rebuild-index! repo))
(js/setTimeout
Expand Down
18 changes: 4 additions & 14 deletions src/main/frontend/mobile/core.cljs
Expand Up @@ -7,12 +7,8 @@
["@capacitor/status-bar" :refer [^js StatusBar]]
[clojure.string :as string]
[frontend.fs.capacitor-fs :as fs]
[frontend.components.repo :as repo]
[frontend.handler.web.nfs :as nfs-handler]
[frontend.handler.editor :as editor-handler]
[promesa.core :as p]
[frontend.util :as util]
[frontend.config :as config]))
[frontend.util :as util]))

(defn- ios-init
[]
Expand Down Expand Up @@ -62,13 +58,7 @@

(.addListener App "appStateChange"
(fn [^js state]
(when-let [repo (state/get-current-repo)]
(let [is-active? (.-isActive state)
repo-dir (config/get-repo-dir repo)]
(if is-active?
(p/do!
(when (mobile-util/native-ios?)
(mobile-util/sync-icloud-repo repo-dir))
(nfs-handler/refresh! repo repo/refresh-cb)
(notification/show! "Notes updated!" :success true))
(when (state/get-current-repo)
(let [is-active? (.-isActive state)]
(when is-active?
(editor-handler/save-current-block!))))))))
8 changes: 0 additions & 8 deletions src/main/frontend/mobile/util.cljs
Expand Up @@ -78,7 +78,6 @@
:iPhoneSE4 {:width 320 :height 568 :statusbar 20}
:iPodtouch5 {:width 320 :height 568 :statusbar 20}}))


(defn get-idevice-model
[]
(when (native-ios?)
Expand Down Expand Up @@ -129,10 +128,3 @@
(if (and model landscape?)
20
(:statusbar (model @idevice-info)))))

(defn icloud-sync!
[]
(let [f (fn []
(.downloadFilesFromiCloud download-icloud-files))]
(f)
(js/setInterval f 300000)))

0 comments on commit 61bff0a

Please sign in to comment.