mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-25 16:09:42 +01:00
web: fix race condition where editor context would be destroyed and updated at the same time
This commit is contained in:
@@ -61,9 +61,11 @@ class EditorManager extends BaseStore<EditorManager> {
|
||||
| ((oldState: EditorContext) => Partial<EditorContext>)
|
||||
) => {
|
||||
this.set((state) => {
|
||||
const oldState = state.editors[id];
|
||||
if (!oldState) return;
|
||||
const newPartialState =
|
||||
typeof partial === "function" ? partial(state.editors[id]) : partial;
|
||||
state.editors[id] = { ...state.editors[id], ...newPartialState };
|
||||
typeof partial === "function" ? partial(oldState) : partial;
|
||||
state.editors[id] = { ...oldState, ...newPartialState };
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user