fix(client): build error and simplify doRefresh in type widgets

This commit is contained in:
Elian Doran 2025-04-07 22:50:38 +03:00
parent c74f51472e
commit 7f1eb99127
No known key found for this signature in database
5 changed files with 9 additions and 10 deletions

View File

@ -168,10 +168,10 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
this.#destroyResizer(); this.#destroyResizer();
} }
async doRefresh(note: FNote | null | undefined) { async doRefresh(note: FNote) {
this.#adjustLayoutOrientation(); this.#adjustLayoutOrientation();
if (note && !this.isReadOnly) { if (!this.isReadOnly) {
await this.editorTypeWidget.initialized; await this.editorTypeWidget.initialized;
this.editorTypeWidget.noteContext = this.noteContext; this.editorTypeWidget.noteContext = this.noteContext;
this.editorTypeWidget.spacedUpdate = this.spacedUpdate; this.editorTypeWidget.spacedUpdate = this.spacedUpdate;

View File

@ -46,7 +46,7 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
$(window).on("resize", this.zoomHandler); $(window).on("resize", this.zoomHandler);
} }
async doRefresh(note: FNote | null | undefined) { async doRefresh(note: FNote) {
super.doRefresh(note); super.doRefresh(note);
const blob = await note?.getBlob(); const blob = await note?.getBlob();

View File

@ -45,9 +45,6 @@ export default class AttachmentListTypeWidget extends TypeWidget {
} }
async doRefresh(note: Parameters<TypeWidget["doRefresh"]>[0]) { async doRefresh(note: Parameters<TypeWidget["doRefresh"]>[0]) {
// TriliumNextTODO: do we need to handle an undefined/null note?
if (!note) return false;
const $helpButton = $(` const $helpButton = $(`
<button class="attachment-help-button icon-action bx bx-help-circle" <button class="attachment-help-button icon-action bx bx-help-circle"
type="button" data-help-page="attachments.html" type="button" data-help-page="attachments.html"

View File

@ -32,9 +32,9 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
super.doRender(); super.doRender();
} }
async doRefresh(note: FNote | null | undefined) { async doRefresh(note: FNote) {
const blob = await this.note?.getBlob(); 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 isFormattable = note.type === "text" && this.noteContext?.viewScope?.viewMode === "source";
const content = isFormattable ? this.format(blob.content) : blob.content; const content = isFormattable ? this.format(blob.content) : blob.content;

View File

@ -20,7 +20,7 @@ export default abstract class TypeWidget extends NoteContextAwareWidget {
return super.doRender(); return super.doRender();
} }
doRefresh(note: FNote | null | undefined): void | Promise<void> {} doRefresh(note: FNote): void | Promise<void> {}
async refresh() { async refresh() {
const thisWidgetType = (this.constructor as any).getType(); const thisWidgetType = (this.constructor as any).getType();
@ -33,7 +33,9 @@ export default abstract class TypeWidget extends NoteContextAwareWidget {
} else { } else {
this.toggleInt(true); this.toggleInt(true);
await this.doRefresh(this.note); if (this.note) {
await this.doRefresh(this.note);
}
this.triggerEvent("noteDetailRefreshed", { ntxId: this.noteContext?.ntxId }); this.triggerEvent("noteDetailRefreshed", { ntxId: this.noteContext?.ntxId });
} }