From 2a90f4c6e984d55950dd6c8b109727695580f5de Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 8 Feb 2025 21:42:12 +0200 Subject: [PATCH] chore(client/ts): port note_wrapper --- src/public/app/services/load_results.ts | 2 +- .../app/widgets/{note_wrapper.js => note_wrapper.ts} | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) rename src/public/app/widgets/{note_wrapper.js => note_wrapper.ts} (79%) diff --git a/src/public/app/services/load_results.ts b/src/public/app/services/load_results.ts index f87f62ea2..5ebfc7be5 100644 --- a/src/public/app/services/load_results.ts +++ b/src/public/app/services/load_results.ts @@ -158,7 +158,7 @@ export default class LoadResults { return Object.keys(this.noteIdToComponentId); } - isNoteReloaded(noteId: string | undefined, componentId: string | null = null) { + isNoteReloaded(noteId: string | undefined | null, componentId: string | null = null) { if (!noteId) { return false; } diff --git a/src/public/app/widgets/note_wrapper.js b/src/public/app/widgets/note_wrapper.ts similarity index 79% rename from src/public/app/widgets/note_wrapper.js rename to src/public/app/widgets/note_wrapper.ts index 9f045675c..0dc7580a2 100644 --- a/src/public/app/widgets/note_wrapper.js +++ b/src/public/app/widgets/note_wrapper.ts @@ -1,15 +1,21 @@ import FlexContainer from "./containers/flex_container.js"; import utils from "../services/utils.js"; import attributeService from "../services/attributes.js"; +import type BasicWidget from "./basic_widget.js"; +import type { EventData } from "../components/app_context.js"; +import type NoteContext from "../components/note_context.js"; + +export default class NoteWrapperWidget extends FlexContainer { + + private noteContext?: NoteContext; -export default class NoteWrapperWidget extends FlexContainer { constructor() { super("column"); this.css("flex-grow", "1").collapsible(); } - setNoteContextEvent({ noteContext }) { + setNoteContextEvent({ noteContext }: EventData<"setNoteContext">) { this.noteContext = noteContext; this.refresh(); @@ -51,7 +57,7 @@ export default class NoteWrapperWidget extends FlexContainer { this.$widget.toggleClass("protected", note.isProtected); } - async entitiesReloadedEvent({ loadResults }) { + async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { // listening on changes of note.type and CSS class const noteId = this.noteContext?.noteId;