mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
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:
parent
fb0487ca36
commit
223a1fb203
@ -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);
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user