mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-07-10 12:37:16 +02:00
web: fix characters missing sometimes when creating a new note
This commit is contained in:
@@ -57,7 +57,7 @@ import {
|
||||
downloadAttachment,
|
||||
previewImageAttachment
|
||||
} from "../../common/attachments";
|
||||
import { EV, EVENTS } from "@notesnook/core";
|
||||
import { EVENTS } from "@notesnook/core";
|
||||
import { db } from "../../common/db";
|
||||
import Titlebox, { resizeTextarea } from "./title-box";
|
||||
import Config from "../../utils/config";
|
||||
|
||||
@@ -959,7 +959,18 @@ class EditorStore extends BaseStore<EditorStore> {
|
||||
if (index > -1) {
|
||||
if (options?.force)
|
||||
session.nonce = (state.sessions[index]?.nonce || 0) + 1;
|
||||
state.sessions[index] = session;
|
||||
const oldSession = state.sessions[index];
|
||||
// SPECIAL CASE: when a user types in a new session, it gets converted
|
||||
// into a default session with the same id. In this case, we want to
|
||||
// keep the content that the user has typed in the editor instead of
|
||||
// replacing it with the content of the note (which can be stale).
|
||||
if (
|
||||
oldSession.type === "new" &&
|
||||
session.type === "default" &&
|
||||
!!oldSession.content
|
||||
)
|
||||
state.sessions[index] = { ...session, content: oldSession.content };
|
||||
else state.sessions[index] = session;
|
||||
} else state.sessions.push(session);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user