refactor: FAttachment/Attachment_details - make fields public and get rid of getters

as per
https://github.com/TriliumNext/Notes/pull/1260#discussion_r1966615186
This commit is contained in:
Panagiotis Papadopoulos 2025-02-23 12:49:34 +01:00
parent fb0487ca36
commit 223a1fb203
2 changed files with 7 additions and 19 deletions

View File

@ -19,18 +19,18 @@ export interface FAttachmentRow {
class FAttachment { class FAttachment {
private froca: Froca; private froca: Froca;
attachmentId!: string; attachmentId!: string;
private ownerId!: string; ownerId!: string;
role!: string; role!: string;
mime!: string; mime!: string;
title!: string; title!: string;
isProtected!: boolean; // TODO: Is this used? isProtected!: boolean; // TODO: Is this used?
private dateModified!: string; private dateModified!: string;
utcDateModified!: string; utcDateModified!: string;
private utcDateScheduledForErasureSince!: string; utcDateScheduledForErasureSince!: string;
/** /**
* optionally added to the entity * optionally added to the entity
*/ */
private contentLength!: number; contentLength!: number;
constructor(froca: Froca, row: FAttachmentRow) { constructor(froca: Froca, row: FAttachmentRow) {
/** @type {Froca} */ /** @type {Froca} */
@ -57,18 +57,6 @@ class FAttachment {
return this.froca.notes[this.ownerId]; return this.froca.notes[this.ownerId];
} }
getOwnerId() {
return this.ownerId;
}
getContentLength() {
return this.contentLength;
}
getUtcDateScheduledForErasureSince() {
return this.utcDateScheduledForErasureSince;
}
async getBlob() { async getBlob() {
return await this.froca.getBlob("attachments", this.attachmentId); return await this.froca.getBlob("attachments", this.attachmentId);
} }

View File

@ -126,7 +126,7 @@ export default class AttachmentDetailWidget extends BasicWidget {
this.$wrapper.addClass(this.isFullDetail ? "full-detail" : "list-view"); this.$wrapper.addClass(this.isFullDetail ? "full-detail" : "list-view");
if (!this.isFullDetail) { if (!this.isFullDetail) {
const $link = await linkService.createLink(this.attachment.getOwnerId(), { const $link = await linkService.createLink(this.attachment.ownerId, {
title: this.attachment.title, title: this.attachment.title,
viewScope: { viewScope: {
viewMode: "attachments", viewMode: "attachments",
@ -141,7 +141,7 @@ export default class AttachmentDetailWidget extends BasicWidget {
} }
const $deletionWarning = this.$wrapper.find(".attachment-deletion-warning"); const $deletionWarning = this.$wrapper.find(".attachment-deletion-warning");
const utcDateScheduledForErasureSince = this.attachment.getUtcDateScheduledForErasureSince(); const { utcDateScheduledForErasureSince } = this.attachment;
if (utcDateScheduledForErasureSince) { if (utcDateScheduledForErasureSince) {
this.$wrapper.addClass("scheduled-for-deletion"); this.$wrapper.addClass("scheduled-for-deletion");
@ -166,7 +166,7 @@ export default class AttachmentDetailWidget extends BasicWidget {
$deletionWarning.hide(); $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()); this.$wrapper.find(".attachment-actions-container").append(this.attachmentActionsWidget.render());
const { $renderedContent } = await contentRenderer.getRenderedContent(this.attachment, { imageHasZoom: this.isFullDetail }); 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") { if (this.attachment.role === "image") {
imageService.copyImageReferenceToClipboard(this.$wrapper.find(".attachment-content-wrapper")); imageService.copyImageReferenceToClipboard(this.$wrapper.find(".attachment-content-wrapper"));
} else if (this.attachment.role === "file") { } else if (this.attachment.role === "file") {
const $link = await linkService.createLink(this.attachment.getOwnerId(), { const $link = await linkService.createLink(this.attachment.ownerId, {
referenceLink: true, referenceLink: true,
viewScope: { viewScope: {
viewMode: "attachments", viewMode: "attachments",