Skip to content

Commit

Permalink
Merge pull request #4990 from nextcloud/fix/stable26-docStateVersion
Browse files Browse the repository at this point in the history
[stable26] fix(SyncService): handle failing connection gracefully
  • Loading branch information
mejo- authored Nov 14, 2023
2 parents 87db04b + 62b6712 commit 83c4bb6
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 21 deletions.
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

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 83c4bb6

Please sign in to comment.