share functionality WIP

This commit is contained in:
zadam
2021-12-06 22:53:17 +01:00
parent 67da877135
commit 08e8047d8a
5 changed files with 64 additions and 33 deletions

View File

@@ -8,7 +8,7 @@ const LABEL = 'label';
const RELATION = 'relation';
class Note extends AbstractEntity {
constructor([noteId, title, type, mime]) {
constructor([noteId, title, type, mime, utcDateModified]) {
super();
/** @param {string} */
@@ -19,6 +19,8 @@ class Note extends AbstractEntity {
this.type = type;
/** @param {string} */
this.mime = mime;
/** @param {string} */
this.utcDateModified = utcDateModified; // used for caching of images
/** @param {Branch[]} */
this.parentBranches = [];
@@ -438,16 +440,6 @@ class Note extends AbstractEntity {
return !!this.ownedAttributes.find(attr => attr.type === 'label' && attr.name === 'archived' && attr.isInheritable);
}
// will sort the parents so that non-search & non-archived are first and archived at the end
// this is done so that non-search & non-archived paths are always explored as first when looking for note path
resortParents() {
this.parentBranches.sort((a, b) =>
a.branchId.startsWith('virt-')
|| a.parentNote.hasInheritableOwnedArchivedLabel() ? 1 : -1);
this.parents = this.parentBranches.map(branch => branch.parentNote);
}
isTemplate() {
return !!this.targetRelations.find(rel => rel.name === 'template');
}