From 70756fe7955a1ecbaf37d95b672ca510c9435ca7 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sat, 22 Feb 2025 16:58:55 +0100 Subject: [PATCH] chore(ts): start port of type_widgets/attachment_detail --- .../{attachment_detail.js => attachment_detail.ts} | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) rename src/public/app/widgets/type_widgets/{attachment_detail.js => attachment_detail.ts} (84%) diff --git a/src/public/app/widgets/type_widgets/attachment_detail.js b/src/public/app/widgets/type_widgets/attachment_detail.ts similarity index 84% rename from src/public/app/widgets/type_widgets/attachment_detail.js rename to src/public/app/widgets/type_widgets/attachment_detail.ts index 108c5da2e..5fc8e4201 100644 --- a/src/public/app/widgets/type_widgets/attachment_detail.js +++ b/src/public/app/widgets/type_widgets/attachment_detail.ts @@ -4,6 +4,8 @@ import linkService from "../../services/link.js"; import froca from "../../services/froca.js"; import utils from "../../services/utils.js"; import { t } from "../../services/i18n.js"; +import type FNote from "../../entities/fnote.js"; +import type { EventData } from "../../components/app_context.js"; const TPL = `
@@ -32,6 +34,9 @@ const TPL = `
`; export default class AttachmentDetailTypeWidget extends TypeWidget { + $wrapper!: JQuery; + $linksWrapper!: JQuery; + static getType() { return "attachmentDetail"; } @@ -44,7 +49,7 @@ export default class AttachmentDetailTypeWidget extends TypeWidget { super.doRender(); } - async doRefresh(note) { + async doRefresh(note: Parameters[0]) { this.$wrapper.empty(); this.children = []; @@ -69,7 +74,7 @@ export default class AttachmentDetailTypeWidget extends TypeWidget { $helpButton ); - const attachment = await froca.getAttachment(this.attachmentId, true); + const attachment = (this.attachmentId) ? await froca.getAttachment(this.attachmentId, true) : null; if (!attachment) { this.$wrapper.html("" + t("attachment_detail.attachment_deleted") + ""); @@ -82,7 +87,7 @@ export default class AttachmentDetailTypeWidget extends TypeWidget { this.$wrapper.append(attachmentDetailWidget.render()); } - async entitiesReloadedEvent({ loadResults }) { + async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { const attachmentRow = loadResults.getAttachmentRows().find((att) => att.attachmentId === this.attachmentId); if (attachmentRow?.isDeleted) { @@ -91,6 +96,6 @@ export default class AttachmentDetailTypeWidget extends TypeWidget { } get attachmentId() { - return this.noteContext.viewScope.attachmentId; + return this?.noteContext?.viewScope?.attachmentId; } }