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
fix(client): build error and simplify doRefresh in type widgets
Elian Doran7f1eb9912708
diff --git a/src/public/app/widgets/type_widgets/abstract_split_type_widget.ts b/src/public/app/widgets/type_widgets/abstract_split_type_widget.tsindex 72bb6bb235..3b1cb222b9 100644--- a/src/public/app/widgets/type_widgets/abstract_split_type_widget.ts+++ b/src/public/app/widgets/type_widgets/abstract_split_type_widget.ts@@ -168,10 +168,10 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {this.#destroyResizer();}- async doRefresh(note: FNote | null | undefined) {+ async doRefresh(note: FNote) {this.#adjustLayoutOrientation();- if (note && !this.isReadOnly) {+ if (!this.isReadOnly) {await this.editorTypeWidget.initialized;this.editorTypeWidget.noteContext = this.noteContext;this.editorTypeWidget.spacedUpdate = this.spacedUpdate;diff --git a/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.ts b/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.tsindex 061694349c..24c2c1ae49 100644--- a/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.ts+++ b/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.ts@@ -46,7 +46,7 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy$(window).on("resize", this.zoomHandler);}- async doRefresh(note: FNote | null | undefined) {+ async doRefresh(note: FNote) {super.doRefresh(note);const blob = await note?.getBlob();diff --git a/src/public/app/widgets/type_widgets/attachment_list.ts b/src/public/app/widgets/type_widgets/attachment_list.tsindex cdb5161bcd..aced1223c2 100644--- a/src/public/app/widgets/type_widgets/attachment_list.ts+++ b/src/public/app/widgets/type_widgets/attachment_list.ts@@ -45,9 +45,6 @@ export default class AttachmentListTypeWidget extends TypeWidget {}async doRefresh(note: Parameters<TypeWidget["doRefresh"]>[0]) {- // TriliumNextTODO: do we need to handle an undefined/null note?- if (!note) return false;-const $helpButton = $(`<button class="attachment-help-button icon-action bx bx-help-circle"type="button" data-help-page="attachments.html"diff --git a/src/public/app/widgets/type_widgets/read_only_code.ts b/src/public/app/widgets/type_widgets/read_only_code.tsindex 14c7f8ed14..9bdeee1504 100644--- a/src/public/app/widgets/type_widgets/read_only_code.ts+++ b/src/public/app/widgets/type_widgets/read_only_code.ts@@ -32,9 +32,9 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {super.doRender();}- async doRefresh(note: FNote | null | undefined) {+ async doRefresh(note: FNote) {const blob = await this.note?.getBlob();- if (!blob || !note) return false;+ if (!blob) return;const isFormattable = note.type === "text" && this.noteContext?.viewScope?.viewMode === "source";const content = isFormattable ? this.format(blob.content) : blob.content;diff --git a/src/public/app/widgets/type_widgets/type_widget.ts b/src/public/app/widgets/type_widgets/type_widget.tsindex 54282795ce..02257b19e6 100644--- a/src/public/app/widgets/type_widgets/type_widget.ts+++ b/src/public/app/widgets/type_widgets/type_widget.ts@@ -20,7 +20,7 @@ export default abstract class TypeWidget extends NoteContextAwareWidget {return super.doRender();}- doRefresh(note: FNote | null | undefined): void | Promise<void> {}+ doRefresh(note: FNote): void | Promise<void> {}async refresh() {const thisWidgetType = (this.constructor as any).getType();@@ -33,7 +33,9 @@ export default abstract class TypeWidget extends NoteContextAwareWidget {} else {this.toggleInt(true);- await this.doRefresh(this.note);+ if (this.note) {+ await this.doRefresh(this.note);+ }this.triggerEvent("noteDetailRefreshed", { ntxId: this.noteContext?.ntxId });}