Skip to content

Commit

Permalink
feat: Add realtime behing flag
Browse files Browse the repository at this point in the history
  Since we're not completely sure the implementation of realtime
  reaction to remote changes is functionnal, we'll put it behind a local
  feature flag.
  • Loading branch information
taratatach committed Sep 21, 2023
1 parent 623e1b0 commit 380fc52
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions core/remote/watcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ class RemoteWatcher {
this.remoteCozy = remoteCozy
this.events = events
this.running = false
this.realtimeManager = new RealtimeManager()

if (config.flags['desktop.realtime.enabled']) {
this.realtimeManager = new RealtimeManager()
}

this.startQueue()

autoBind(this)
Expand All @@ -109,20 +113,28 @@ class RemoteWatcher {
log.debug('Starting watcher')
this.running = true
this.startClock()
const client = await this.remoteCozy.getClient()
this.realtimeManager.setup({
client,
eventHandler: this.requestRun.bind(this)
})
await this.realtimeManager.start()

if (this.realtimeManager) {
const client = await this.remoteCozy.getClient()
this.realtimeManager.setup({
client,
eventHandler: this.requestRun.bind(this)
})
await this.realtimeManager.start()
}

await this.requestRun()
}
}

async stop() {
if (this.running) {
log.debug('Stopping watcher')
this.realtimeManager.stop()

if (this.realtimeManager) {
this.realtimeManager.stop()
}

this.stopClock()
await this.stopQueue()
this.running = false
Expand Down

0 comments on commit 380fc52

Please sign in to comment.