Skip to content

Build your personal knowledge base with Trilium Notes

chore(react): finalize note title porting

Elian Doran009fd63ce98f
diff --git a/apps/client/src/widgets/note_title.bak b/apps/client/src/widgets/note_title.bak
deleted file mode 100644
index 412934e9de..0000000000
--- a/apps/client/src/widgets/note_title.bak
+++ /dev/null
@@ -1,39 +0,0 @@
-import NoteContextAwareWidget from "./note_context_aware_widget.js";
-import SpacedUpdate from "../services/spaced_update.js";
-import appContext, { type EventData } from "../components/app_context.js";
-import branchService from "../services/branches.js";
-import shortcutService from "../services/shortcuts.js";
-
-export default class NoteTitleWidget extends NoteContextAwareWidget {
-
- private $noteTitle!: JQuery<HTMLElement>;
- private deleteNoteOnEscape: boolean;
-
- constructor() {
- super();
-
- this.deleteNoteOnEscape = false;
- }
-
- doRender() {
- this.$widget = $(TPL);
- this.$noteTitle = this.$widget.find(".note-title");
- this.$noteTitle.on("blur", () => {
-
- });
-
- }
-
- async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) {
- if (this.isNoteContext(noteContext.ntxId)) {
- await this.spacedUpdate.updateNowIfNecessary();
- }
- }
-
- async beforeNoteContextRemoveEvent({ ntxIds }: EventData<"beforeNoteContextRemove">) {
- if (this.isNoteContext(ntxIds)) {
- await this.spacedUpdate.updateNowIfNecessary();
- }
- }
-
-}
diff --git a/apps/client/src/widgets/note_title.tsx b/apps/client/src/widgets/note_title.tsx
index 9d1522740d..adef54bc9e 100644
--- a/apps/client/src/widgets/note_title.tsx
+++ b/apps/client/src/widgets/note_title.tsx
@@ -48,6 +48,7 @@ export default function NoteTitleWidget() {
useEffect(() => {
appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());
}, []);
+ useTriliumEventBeta([ "beforeNoteSwitch", "beforeNoteContextRemove" ], () => spacedUpdate.updateNowIfNecessary());
// Manage focus.
const textBoxRef = useRef<HTMLInputElement>(null);