Skip to content

Commit

Permalink
fix(SyncService): handle failing connection gracefully
Browse files Browse the repository at this point in the history
Also fixes the share cypress test.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud authored and mejo- committed Nov 14, 2023
1 parent 87db04b commit 6164fb6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/services/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,22 @@ class SyncService {
}

async open({ fileId, initialSession }) {
this.on('change', ({ sessions }) => {
const onChange = ({ sessions }) => {
this.sessions = sessions
})
}
this.on('change', onChange)

const connect = initialSession
? Promise.resolve(new Connection({ data: initialSession }, {}))
: this._api.open({ fileId })
.catch(error => this._emitError(error))

// TODO: Only continue if a connection was made
this.connection = await connect
if (!this.connection) {
this.off('change', onChange)
// Error was already emitted in connect
return
}
this.backend = new PollingBackend(this, this.connection)
this.version = this.connection.docStateVersion
this.emit('opened', {
Expand Down

0 comments on commit 6164fb6

Please sign in to comment.