UBERF-4777 Fix redundant updates from collaborator (#4280)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2023-12-28 10:33:44 +07:00 committed by GitHub
parent f4d6faf4f8
commit 5ddcaf4051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -314,7 +314,11 @@
</div>
{/if}
<div class="text-editor-toolbar buttons-group xsmall-gap mb-4" bind:this={textToolbarElement}>
<div
class="text-editor-toolbar buttons-group xsmall-gap mb-4"
bind:this={textToolbarElement}
style="visibility: hidden;"
>
{#if showTextStyleToolbar}
<TextEditorStyleToolbar
textEditor={editor}
@ -326,7 +330,11 @@
{/if}
</div>
<div class="text-editor-toolbar buttons-group xsmall-gap mb-4" bind:this={imageToolbarElement}>
<div
class="text-editor-toolbar buttons-group xsmall-gap mb-4"
bind:this={imageToolbarElement}
style="visibility: hidden;"
>
<ImageStyleToolbar textEditor={editor} formatButtonSize={buttonSize} on:focus={handleFocus} />
</div>

View File

@ -54,13 +54,14 @@ export class StorageExtension implements Extension {
async onStoreDocument ({ context, documentName, document }: withContext<onStoreDocumentPayload>): Promise<void> {
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<onDisconnectPayload>): Promise<any> {
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)
})
}