Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: session history cannot be previewed

thecodrrfdf2d908599c
diff --git a/apps/web/__e2e__/editor.test.js b/apps/web/__e2e__/editor.test.js
index 42d052296..e356c4b98 100644
--- a/apps/web/__e2e__/editor.test.js
+++ b/apps/web/__e2e__/editor.test.js
@@ -311,3 +311,21 @@ test("editing a note and switching immediately to another note and editing the t
`fast-switch-and-edit-note-title-1.txt`
);
});
+
+test("editing a note and toggling read-only mode should show updated content", async () => {
+ const selector = await createNoteAndCheckPresence();
+
+ await page.click(getTestId("notes-action-button"));
+
+ await page.click(selector);
+
+ await editNote(null, `An edit I made`, false);
+
+ await page.click(getTestId("properties"));
+
+ await page.click(getTestId("properties-readonly"));
+
+ await page.click(getTestId("properties-close"));
+
+ expect(await getEditorContent()).toMatchSnapshot(`readonly-edited-note.txt`);
+});
diff --git a/apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-Chromium-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-Chromium-linux.txt
new file mode 100644
index 000000000..8fdeb8f1c
--- /dev/null
+++ b/apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-Chromium-linux.txt
@@ -0,0 +1 @@
+An edit I madeThis is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1
\ No newline at end of file
diff --git a/apps/web/__e2e__/tags.test.js b/apps/web/__e2e__/tags.test.js
index af47c194c..4d36e8fb6 100644
--- a/apps/web/__e2e__/tags.test.js
+++ b/apps/web/__e2e__/tags.test.js
@@ -94,6 +94,8 @@ test("delete a tag", async ({ page }) => {
await clickMenuItem("delete");
});
+ await page.waitForTimeout(1000);
+
expect(await page.isVisible(tagSelector.build())).toBe(false);
});
@@ -221,6 +223,8 @@ test("delete the last note of a tag that is also a shortcut", async ({
await clickMenuItem("movetotrash");
});
+ await page.waitForTimeout(1000);
+
expect(await page.isVisible(noteSelector)).toBe(false);
await navigateTo("notes");
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx
index 8013204c8..4706a4606 100644
--- a/apps/web/src/components/editor/index.tsx
+++ b/apps/web/src/components/editor/index.tsx
@@ -68,13 +68,11 @@ export default function EditorManager({
const title = useRef<string>("");
const previewSession = useRef<PreviewSession>();
const [dropRef, overlayRef] = useDragOverlay();
- const editor = useEditorInstance();
const arePropertiesVisible = useStore((store) => store.arePropertiesVisible);
const toggleProperties = useStore((store) => store.toggleProperties);
- const isReadonly = useStore(
- (store) => store.session.readonly || !!previewSession.current
- );
+ const isReadonly = useStore((store) => store.session.readonly);
+ const isPreviewSession = !!previewSession.current;
const openSession = useCallback(async (noteId) => {
await editorstore.get().openSession(noteId);
@@ -141,7 +139,7 @@ export default function EditorManager({
title={title.current}
content={content.current}
options={{
- readonly: isReadonly,
+ readonly: isReadonly || isPreviewSession,
onRequestFocus: () => toggleProperties(false),
onLoadMedia: loadMedia,
}}