A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: always show note statistics of active editor
Abdullah Atta0e4a2c759319
diff --git a/apps/web/src/components/editor/footer.tsx b/apps/web/src/components/editor/footer.tsxindex 4177742ef..91480cbd9 100644--- a/apps/web/src/components/editor/footer.tsx+++ b/apps/web/src/components/editor/footer.tsx@@ -29,14 +29,12 @@ const SAVE_STATE_ICON_MAP = {};function EditorFooter() {- const activeSessionId = useEditorStore((store) => store.activeSessionId);- const { words } = useNoteStatistics(activeSessionId || "unknown");+ const { words } = useNoteStatistics();const saveState = useEditorStore((store) => store.getActiveSession(["default"])?.saveState);const SaveStateIcon = saveState ? SAVE_STATE_ICON_MAP[saveState] : null;- if (!activeSessionId) return null;return (<Flex sx={{ alignItems: "center" }}><Textdiff --git a/apps/web/src/components/editor/manager.ts b/apps/web/src/components/editor/manager.tsindex ec3f44d7f..9f1da6492 100644--- a/apps/web/src/components/editor/manager.ts+++ b/apps/web/src/components/editor/manager.ts@@ -35,6 +35,7 @@ type EditorContext = {};class EditorManager extends BaseStore<EditorManager> {+ activeEditorId?: string;toolbarConfig?: ToolbarDefinition;editorConfig: EditorConfig = Config.get("editorConfig", {fontFamily: "sans-serif",@@ -50,6 +51,11 @@ class EditorManager extends BaseStore<EditorManager> {this.set((state) => {if (!editor) delete state.editors[id];else state.editors[id] = editor;+ state.activeEditorId = editor+ ? id+ : id === state.activeEditorId+ ? undefined+ : state.activeEditorId;});};@@ -62,6 +68,7 @@ class EditorManager extends BaseStore<EditorManager> {this.set((state) => {const oldState = state.editors[id];if (!oldState) return;+ state.activeEditorId = id;const newPartialState =typeof partial === "function" ? partial(oldState) : partial;state.editors[id] = { ...oldState, ...newPartialState };@@ -105,10 +112,11 @@ export function useToolbarConfig() {return { toolbarConfig, setToolbarConfig };}-export function useNoteStatistics(id: string): NoteStatistics {+export function useNoteStatistics(): NoteStatistics {return useEditorManager((store) =>- store.editors[id]?.statistics || {+ (store.activeEditorId &&+ store.editors[store.activeEditorId]?.statistics) || {words: { total: 0 }});