mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 03:46:37 +01:00
wip attachment support
This commit is contained in:
@@ -51,6 +51,9 @@ class FNote {
|
||||
/** @type {Object.<string, string>} */
|
||||
this.childToBranch = {};
|
||||
|
||||
/** @type {FAttachment[]|null} */
|
||||
this.attachments = null; // lazy loaded
|
||||
|
||||
this.update(row);
|
||||
}
|
||||
|
||||
@@ -225,6 +228,23 @@ class FNote {
|
||||
return await this.froca.getNotes(this.children);
|
||||
}
|
||||
|
||||
/** @returns {Promise<FAttachment[]>} */
|
||||
async getAttachments() {
|
||||
if (!this.attachments) {
|
||||
this.attachments = (await server.get(`notes/${this.noteId}/attachments`))
|
||||
.map(row => new FAttachment(froca, row));
|
||||
}
|
||||
|
||||
return this.attachments;
|
||||
}
|
||||
|
||||
/** @returns {Promise<FAttachment>} */
|
||||
async getAttachmentById(attachmentId) {
|
||||
const attachments = await this.getAttachments();
|
||||
|
||||
return attachments.find(att => att.attachmentId === attachmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [type] - (optional) attribute type to filter
|
||||
* @param {string} [name] - (optional) attribute name to filter
|
||||
|
||||
Reference in New Issue
Block a user