Skip to content

Commit

Permalink
cap sync
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Nov 11, 2022
1 parent 085d9b3 commit 3b399d3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
implementation project(':capacitor-share')
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':capawesome-capacitor-background-task')
implementation project(':logseq-capacitor-file-sync')
implementation project(':capacitor-voice-recorder')
implementation project(':send-intent')
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/assets/capacitor.plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"pkg": "@capacitor/status-bar",
"classpath": "com.capacitorjs.plugins.statusbar.StatusBarPlugin"
},
{
"pkg": "@capawesome/capacitor-background-task",
"classpath": "io.capawesome.capacitorjs.plugins.backgroundtask.BackgroundTaskPlugin"
},
{
"pkg": "@logseq/capacitor-file-sync",
"classpath": "com.logseq.app.filesync.FileSyncPlugin"
Expand Down
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capa
include ':capacitor-status-bar'
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')

include ':capawesome-capacitor-background-task'
project(':capawesome-capacitor-background-task').projectDir = new File('../node_modules/@capawesome/capacitor-background-task/android')

include ':logseq-capacitor-file-sync'
project(':logseq-capacitor-file-sync').projectDir = new File('../node_modules/@logseq/capacitor-file-sync/android')

Expand Down
1 change: 1 addition & 0 deletions ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>processing</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
Expand Down
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def capacitor_pods
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
pod 'CapawesomeCapacitorBackgroundTask', :path => '../../node_modules/@capawesome/capacitor-background-task'
pod 'LogseqCapacitorFileSync', :path => '../../node_modules/@logseq/capacitor-file-sync'
pod 'CapacitorVoiceRecorder', :path => '../../node_modules/capacitor-voice-recorder'
pod 'SendIntent', :path => '../../node_modules/send-intent'
Expand Down
25 changes: 14 additions & 11 deletions src/main/frontend/fs/sync.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2939,7 +2939,7 @@
base-path
repo *sync-state remoteapi-with-stop
(if (mobile-util/native-platform?)
2000
10000
10000)
*txid nil (chan) *stopped? *paused?
(chan 1) (chan 1))
Expand Down Expand Up @@ -3000,16 +3000,19 @@
(mobile-util/native-ios?)
(let [*task-id (atom nil)]
(when (and (not is-active?) (state/get-current-file-sync-graph-uuid))
(go
;; Wait for file watcher events
(<! (timeout 2000))
(<! (<sync-local->remote-now))

(p/let [task-id (.beforeExit ^js BackgroundTask
(fn []
(<! finished-local->remote-chan)
(.finish ^js BackgroundTask @*task-id)))]
(reset! *task-id task-id)))))
(p/let [task-id (.beforeExit ^js BackgroundTask
(fn []
(prn "before exit")
(go
;; Wait for file watcher events
(<! (timeout 2000))
(<! (<sync-local->remote-now))
(<! finished-local->remote-chan)
(prn "finish task: " @*task-id)
(let [opt #js {:taskId @*task-id}]
(.finish ^js BackgroundTask opt)))))]

(reset! *task-id task-id))))

:else
nil)))
Expand Down

0 comments on commit 3b399d3

Please sign in to comment.