From be6da38a0808156f5bf87624e7399fa19c0f19d0 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 11 Dec 2024 19:38:08 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20only=20owner=20will=20?= =?UTF-8?q?make=20initial=20content?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases, the sync of the initial content is not being done correctly. We will let only the owner of the document to make the initial content. --- src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts | 1 + .../apps/e2e/__tests__/app-impress/doc-header.spec.ts | 4 +++- .../features/docs/doc-editor/components/BlockNoteEditor.tsx | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts index 16f1ffdb..ebb32cce 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts @@ -93,6 +93,7 @@ test.describe('Config', () => { const fileChooserPromise = page.waitForEvent('filechooser'); + await page.locator('.bn-block-outer').last().fill('Anything'); await page.locator('.bn-block-outer').last().fill('/'); await page.getByText('Resizable image with caption').click(); await page.getByText('Upload image').click(); diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts index 37a98764..f2c7d679 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts @@ -124,7 +124,9 @@ test.describe('Doc Header', () => { .getByRole('heading', { name: 'Top World', level: 2 }) .fill(' '); - await page.getByText('Created at').click(); + await page.getByText('Created at').click({ + delay: 200, + }); await expect( docHeader.getByRole('heading', { name: 'Untitled document', level: 2 }), diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx index afd7a9fa..ebf96df6 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx @@ -10,7 +10,7 @@ import * as Y from 'yjs'; import { Box, TextErrors } from '@/components'; import { useAuthStore } from '@/core/auth'; -import { Doc } from '@/features/docs/doc-management'; +import { Doc, Role, currentDocRole } from '@/features/docs/doc-management'; import { useUploadFile } from '../hook'; import { useHeadings } from '../hook/useHeadings'; @@ -133,7 +133,7 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { * better to let Blocknote manage, then we update the block with the content. */ useEffect(() => { - if (doc.content) { + if (doc.content || currentDocRole(doc.abilities) !== Role.OWNER) { return; } @@ -143,7 +143,7 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { content: '', }); }, 100); - }, [editor, doc.content]); + }, [editor, doc.content, doc.abilities]); useEffect(() => { setEditor(editor);