Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(SyncService): handle failing connection gracefully
Also fixes the share cypress test.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud authored and mejo- committed Nov 14, 2023
commit 6164fb6b91dd1538f1e36bb928a944e2d5becaed
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