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
Prev Previous commit
Next Next commit
chore(refactor): replace $providers with syncProvider
Move its definition into the setup function.

One problem that becomes apparent here - but that we probably already have:
On a reconnect the provider will change.
But it remains the same in the collaboration cursor extension
effectively disconnecting the two.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Jun 30, 2025
commit 12547cc05a3d8ce4900309db066ac7eddabcc35e
13 changes: 6 additions & 7 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export default {
getDocumentState: () => getDocumentState(ydoc),
})
}
const syncProvider = shallowRef(null)

return {
baseVersionEtag,
Expand All @@ -284,6 +285,7 @@ export default {
lowlightLoaded,
requireReconnect,
setEditable,
syncProvider,
syncService,
width,
wrappedConnection,
Expand Down Expand Up @@ -414,14 +416,13 @@ export default {
// console.debug('ydoc update', update, origin, doc, tr)
// Y.logUpdate(update)
// });
this.$providers = []
this.$attachmentResolver = null
if (this.active && this.hasDocumentParameters) {
this.initSession()
const extensions = [
Autofocus.configure({ fileId: this.fileId }),
Collaboration.configure({ document: this.ydoc }),
CollaborationCursor.configure({ provider: this.$providers[0] }),
CollaborationCursor.configure({ provider: this.syncProvider }),
]
this.editor = this.isRichEditor
? createRichEditor({
Expand Down Expand Up @@ -454,14 +455,13 @@ export default {
initSession() {
this.connectSyncService()
this.listenSyncServiceEvents()
const syncServiceProvider = createSyncServiceProvider({
this.syncProvider = createSyncServiceProvider({
ydoc: this.ydoc,
syncService: this.syncService,
fileId: this.fileId,
initialSession: this.initialSession,
disableBC: true,
})
this.$providers.push(syncServiceProvider)
},

listenEditorEvents() {
Expand Down Expand Up @@ -643,7 +643,7 @@ export default {
onSync({ steps, document }) {
this.hasConnectionIssue =
this.syncService.backend.fetcher === 0
|| !this.$providers[0].wsconnected
|| !this.syncProvider?.wsconnected
|| this.syncService.pushError > 0
if (this.syncService.pushError > 0) {
// successfully received steps - so let's try and also push
Expand Down Expand Up @@ -765,8 +765,7 @@ export default {
async disconnect() {
await this.syncService.close()
this.unlistenSyncServiceEvents()
this.$providers.forEach((p) => p?.destroy())
this.$providers = []
this.syncProvider?.destroy()
// disallow editing while still showing the content
this.readOnly = true
},
Expand Down