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
refactor: FAttachment/Attachment_details - make fields public and get rid of getters
Panagiotis Papadopoulos223a1fb20314
diff --git a/src/public/app/entities/fattachment.ts b/src/public/app/entities/fattachment.tsindex 3966a2e05e..4774f87bd5 100644--- a/src/public/app/entities/fattachment.ts+++ b/src/public/app/entities/fattachment.ts@@ -19,18 +19,18 @@ export interface FAttachmentRow {class FAttachment {private froca: Froca;attachmentId!: string;- private ownerId!: string;+ ownerId!: string;role!: string;mime!: string;title!: string;isProtected!: boolean; // TODO: Is this used?private dateModified!: string;utcDateModified!: string;- private utcDateScheduledForErasureSince!: string;+ utcDateScheduledForErasureSince!: string;/*** optionally added to the entity*/- private contentLength!: number;+ contentLength!: number;constructor(froca: Froca, row: FAttachmentRow) {/** @type {Froca} */@@ -57,18 +57,6 @@ class FAttachment {return this.froca.notes[this.ownerId];}- getOwnerId() {- return this.ownerId;- }-- getContentLength() {- return this.contentLength;- }-- getUtcDateScheduledForErasureSince() {- return this.utcDateScheduledForErasureSince;- }-async getBlob() {return await this.froca.getBlob("attachments", this.attachmentId);}diff --git a/src/public/app/widgets/attachment_detail.ts b/src/public/app/widgets/attachment_detail.tsindex 30b5b23034..a66ae95a1f 100644--- a/src/public/app/widgets/attachment_detail.ts+++ b/src/public/app/widgets/attachment_detail.ts@@ -126,7 +126,7 @@ export default class AttachmentDetailWidget extends BasicWidget {this.$wrapper.addClass(this.isFullDetail ? "full-detail" : "list-view");if (!this.isFullDetail) {- const $link = await linkService.createLink(this.attachment.getOwnerId(), {+ const $link = await linkService.createLink(this.attachment.ownerId, {title: this.attachment.title,viewScope: {viewMode: "attachments",@@ -141,7 +141,7 @@ export default class AttachmentDetailWidget extends BasicWidget {}const $deletionWarning = this.$wrapper.find(".attachment-deletion-warning");- const utcDateScheduledForErasureSince = this.attachment.getUtcDateScheduledForErasureSince();+ const { utcDateScheduledForErasureSince } = this.attachment;if (utcDateScheduledForErasureSince) {this.$wrapper.addClass("scheduled-for-deletion");@@ -166,7 +166,7 @@ export default class AttachmentDetailWidget extends BasicWidget {$deletionWarning.hide();}- this.$wrapper.find(".attachment-details").text(t("attachment_detail_2.role_and_size", { role: this.attachment.role, size: utils.formatSize(this.attachment.getContentLength()) }));+ this.$wrapper.find(".attachment-details").text(t("attachment_detail_2.role_and_size", { role: this.attachment.role, size: utils.formatSize(this.attachment.contentLength) }));this.$wrapper.find(".attachment-actions-container").append(this.attachmentActionsWidget.render());const { $renderedContent } = await contentRenderer.getRenderedContent(this.attachment, { imageHasZoom: this.isFullDetail });@@ -177,7 +177,7 @@ export default class AttachmentDetailWidget extends BasicWidget {if (this.attachment.role === "image") {imageService.copyImageReferenceToClipboard(this.$wrapper.find(".attachment-content-wrapper"));} else if (this.attachment.role === "file") {- const $link = await linkService.createLink(this.attachment.getOwnerId(), {+ const $link = await linkService.createLink(this.attachment.ownerId, {referenceLink: true,viewScope: {viewMode: "attachments",