+
diff --git a/server/collaborator/src/extensions/storage.ts b/server/collaborator/src/extensions/storage.ts
index 0f61aad03e..9d6c542921 100644
--- a/server/collaborator/src/extensions/storage.ts
+++ b/server/collaborator/src/extensions/storage.ts
@@ -54,13 +54,14 @@ export class StorageExtension implements Extension {
async onStoreDocument ({ context, documentName, document }: withContext
): Promise {
const collaborators = this.collaborators.get(documentName)
+
if (collaborators === undefined || collaborators.size === 0) {
console.log('no changes for document', documentName)
return
}
+ this.collaborators.delete(documentName)
await this.configuration.ctx.with('store-document', {}, async () => {
- this.collaborators.delete(documentName)
await this.storeDocument(documentName, document, context)
})
}
@@ -68,12 +69,14 @@ export class StorageExtension implements Extension {
async onDisconnect ({ context, documentName, document }: withContext): Promise {
const { connectionId } = context
const collaborators = this.collaborators.get(documentName)
- if (collaborators === undefined || !this.collaborators.has(connectionId)) {
+
+ if (collaborators === undefined || !collaborators.has(connectionId)) {
console.log('no changes for document', documentName)
+ return
}
+ this.collaborators.delete(documentName)
await this.configuration.ctx.with('store-document', {}, async () => {
- this.collaborators.get(documentName)?.delete(connectionId)
await this.storeDocument(documentName, document, context)
})
}