mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
refactoring for archived notes handling in note cache
This commit is contained in:
@@ -138,12 +138,6 @@ class Note {
|
||||
return this.hasAttribute('label', 'archived');
|
||||
}
|
||||
|
||||
get isHideInAutocompleteOrArchived() {
|
||||
return this.attributes.find(attr =>
|
||||
attr.type === 'label'
|
||||
&& ["archived", "hideInAutocomplete"].includes(attr.name));
|
||||
}
|
||||
|
||||
get hasInheritableOwnedArchivedLabel() {
|
||||
return !!this.ownedAttributes.find(attr => attr.type === 'label' && attr.name === 'archived' && attr.isInheritable);
|
||||
}
|
||||
@@ -155,20 +149,19 @@ class Note {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string} - returns flattened textual representation of note, prefixes and attributes usable for searching
|
||||
* This is used for:
|
||||
* - fast searching
|
||||
* - note similarity evaluation
|
||||
*
|
||||
* @return {string} - returns flattened textual representation of note, prefixes and attributes
|
||||
*/
|
||||
get flatText() {
|
||||
if (!this.flatTextCache) {
|
||||
if (this.isHideInAutocompleteOrArchived) {
|
||||
this.flatTextCache = " "; // can't be empty
|
||||
return this.flatTextCache;
|
||||
}
|
||||
|
||||
this.flatTextCache = this.noteId + ' ' + this.type + ' ' + this.mime;
|
||||
this.flatTextCache = this.noteId + ' ' + this.type + ' ' + this.mime + ' ';
|
||||
|
||||
for (const branch of this.parentBranches) {
|
||||
if (branch.prefix) {
|
||||
this.flatTextCache += branch.prefix + ' - ';
|
||||
this.flatTextCache += branch.prefix + ' ';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,11 +169,13 @@ class Note {
|
||||
|
||||
for (const attr of this.attributes) {
|
||||
// it's best to use space as separator since spaces are filtered from the search string by the tokenization into words
|
||||
this.flatTextCache += ' ' + (attr.type === 'label' ? '#' : '@') + attr.name;
|
||||
this.flatTextCache += (attr.type === 'label' ? '#' : '~') + attr.name;
|
||||
|
||||
if (attr.value) {
|
||||
this.flatTextCache += '=' + attr.value;
|
||||
}
|
||||
|
||||
this.flatTextCache += ' ';
|
||||
}
|
||||
|
||||
this.flatTextCache = this.flatTextCache.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user