Skip to content

Commit be6da38

Browse files
committed
🐛(frontend) only owner will make initial content
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.
1 parent fc36ed0 commit be6da38

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ test.describe('Config', () => {
9393

9494
const fileChooserPromise = page.waitForEvent('filechooser');
9595

96+
await page.locator('.bn-block-outer').last().fill('Anything');
9697
await page.locator('.bn-block-outer').last().fill('/');
9798
await page.getByText('Resizable image with caption').click();
9899
await page.getByText('Upload image').click();

src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ test.describe('Doc Header', () => {
124124
.getByRole('heading', { name: 'Top World', level: 2 })
125125
.fill(' ');
126126

127-
await page.getByText('Created at').click();
127+
await page.getByText('Created at').click({
128+
delay: 200,
129+
});
128130

129131
await expect(
130132
docHeader.getByRole('heading', { name: 'Untitled document', level: 2 }),

src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Y from 'yjs';
1010

1111
import { Box, TextErrors } from '@/components';
1212
import { useAuthStore } from '@/core/auth';
13-
import { Doc } from '@/features/docs/doc-management';
13+
import { Doc, Role, currentDocRole } from '@/features/docs/doc-management';
1414

1515
import { useUploadFile } from '../hook';
1616
import { useHeadings } from '../hook/useHeadings';
@@ -133,7 +133,7 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {
133133
* better to let Blocknote manage, then we update the block with the content.
134134
*/
135135
useEffect(() => {
136-
if (doc.content) {
136+
if (doc.content || currentDocRole(doc.abilities) !== Role.OWNER) {
137137
return;
138138
}
139139

@@ -143,7 +143,7 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {
143143
content: '',
144144
});
145145
}, 100);
146-
}, [editor, doc.content]);
146+
}, [editor, doc.content, doc.abilities]);
147147

148148
useEffect(() => {
149149
setEditor(editor);

0 commit comments

Comments
 (0)