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;
}
}