Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(right_pane): revert note data store
Elian Doran02294206ecd1
diff --git a/apps/client/src/widgets/react/NoteStore.ts b/apps/client/src/widgets/react/NoteStore.tsdeleted file mode 100644index 6f34c6d23f..0000000000--- a/apps/client/src/widgets/react/NoteStore.ts+++ /dev/null@@ -1,33 +0,0 @@-type Listener = () => void;--class NoteSavedDataStore {- private data = new Map<string, string>();- private listeners = new Map<string, Set<Listener>>();-- get(noteId: string) {- return this.data.get(noteId);- }-- set(noteId: string, value: string) {- this.data.set(noteId, value);- this.listeners.get(noteId)?.forEach(l => l());- }-- subscribe(noteId: string, listener: Listener) {- let set = this.listeners.get(noteId);- if (!set) {- set = new Set();- this.listeners.set(noteId, set);- }- set.add(listener);-- return () => {- set!.delete(listener);- if (set!.size === 0) {- this.listeners.delete(noteId);- }- };- }-}--export const noteSavedDataStore = new NoteSavedDataStore();diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 73fbfc1016..eadbf12a67 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -3,7 +3,7 @@ import { FilterLabelsByType, KeyboardActionNames, OptionNames, RelationNames } fimport { Tooltip } from "bootstrap";import Mark from "mark.js";import { RefObject, VNode } from "preact";-import { CSSProperties, useSyncExternalStore } from "preact/compat";+import { CSSProperties } from "preact/compat";import { MutableRef, useCallback, useContext, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";import appContext, { EventData, EventNames } from "../../components/app_context";@@ -26,8 +26,6 @@ import utils, { escapeRegExp, randomString, reloadFrontendApp } from "../../servimport BasicWidget, { ReactWrappedWidget } from "../basic_widget";import NoteContextAwareWidget from "../note_context_aware_widget";import { DragData } from "../note_tree";-import CKEditor from "./CKEditor";-import { noteSavedDataStore } from "./NoteStore";import { NoteContextContext, ParentComponent, refToJQuerySelector } from "./react_utils";export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) {@@ -115,7 +113,6 @@ export function useEditorSpacedUpdate({ note, noteContext, getData, onContentChaprotected_session_holder.touchProtectedSessionIfNecessary(note);await server.put(`notes/${note.noteId}/data`, data, parentComponent?.componentId);- noteSavedDataStore.set(note.noteId, data.content);dataSaved?.(data);};}, [ note, getData, dataSaved ]);@@ -124,7 +121,6 @@ export function useEditorSpacedUpdate({ note, noteContext, getData, onContentCha// React to note/blob changes.useEffect(() => {if (!blob) return;- noteSavedDataStore.set(note.noteId, blob.content);spacedUpdate.allowUpdateWithoutChange(() => onContentChange(blob.content));}, [ blob ]);@@ -156,14 +152,6 @@ export function useEditorSpacedUpdate({ note, noteContext, getData, onContentChareturn spacedUpdate;}-export function useNoteSavedData(noteId: string | undefined) {- return useSyncExternalStore(- (cb) => noteId ? noteSavedDataStore.subscribe(noteId, cb) : () => {},- () => noteId ? noteSavedDataStore.get(noteId) : undefined- );-}--/*** Allows a React component to read and write a Trilium option, while also watching for external changes.*