diff --git a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml
index 2badc45a5..e820877ad 100644
--- a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml
+++ b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml
@@ -16,806 +16,657 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
+
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
1
-
+
4
INT|0s
1
0
-
+
5
TEXT|0s
1
""
-
+
1
apiTokenId
1
-
+
apiTokenId
1
sqlite_autoindex_api_tokens_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
1
-
+
4
TEXT|0s
1
-
+
5
TEXT|0s
1
''
-
+
6
INT|0s
1
0
-
+
7
TEXT|0s
1
-
+
8
TEXT|0s
1
-
+
9
INT|0s
1
-
+
10
TEXT|0s
1
""
-
+
+ 11
+ int|0s
+ 0
+
+
1
attributeId
1
-
+
attributeId
1
sqlite_autoindex_attributes_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
1
-
+
4
INTEGER|0s
1
-
+
5
TEXT|0s
-
+
6
BOOLEAN|0s
-
+
7
INTEGER|0s
1
0
-
+
8
TEXT|0s
1
-
+
9
TEXT|0s
1
""
-
+
10
TEXT|0s
1
'1970-01-01T00:00:00.000Z'
-
+
1
branchId
1
-
+
noteId
parentNoteId
-
+
noteId
-
+
parentNoteId
-
+
branchId
1
sqlite_autoindex_branches_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
-
+
3
TEXT|0s
-
+
4
TEXT|0s
1
-
+
1
eventId
1
-
+
eventId
1
sqlite_autoindex_event_log_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
1
-
+
4
TEXT|0s
1
-
+
5
BLOB|0s
-
+
6
INT|0s
1
0
-
+
7
TEXT|0s
1
-
+
8
TEXT|0s
1
-
+
9
TEXT|0s
1
""
-
+
1
imageId
1
-
+
imageId
1
sqlite_autoindex_images_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
1
-
- 4
- TEXT|0s
- 1
- ''
-
-
- 5
- INT|0s
- 1
- 0
-
-
- 6
- TEXT|0s
- 1
-
-
- 7
- TEXT|0s
- 1
-
-
- 8
- INT|0s
- 1
-
-
- 9
- TEXT|0s
- 1
- ""
-
-
- 1
- labelId
-
- 1
-
-
- noteId
-
-
-
- noteId
-
-
-
- name
-value
-
-
-
- name
-value
-
-
-
- value
-
-
-
- labelId
- 1
- sqlite_autoindex_labels_1
-
-
- 1
- TEXT|0s
- 1
-
-
- 2
- TEXT|0s
- 1
-
-
- 3
- TEXT|0s
- 1
-
-
+
4
INT|0s
1
0
-
+
5
TEXT|0s
1
-
+
6
TEXT|0s
1
-
+
7
TEXT|0s
1
""
-
+
1
noteImageId
1
-
+
noteId
imageId
-
+
noteId
-
+
imageId
-
+
noteImageId
1
sqlite_autoindex_note_images_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
-
+
4
TEXT|0s
-
+
5
INT|0s
1
0
-
+
6
TEXT|0s
1
-
+
7
TEXT|0s
1
-
+
8
TEXT|0s
1
''
-
+
9
TEXT|0s
1
''
-
+
10
TEXT|0s
1
""
-
+
1
noteRevisionId
1
-
+
noteId
-
+
dateModifiedFrom
-
+
dateModifiedTo
-
+
noteRevisionId
1
sqlite_autoindex_note_revisions_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
"unnamed"
-
+
3
TEXT|0s
1
""
-
+
4
INT|0s
1
0
-
+
5
INT|0s
1
0
-
+
6
TEXT|0s
1
-
+
7
TEXT|0s
1
-
+
8
TEXT|0s
1
'text'
-
+
9
TEXT|0s
1
'text/html'
-
+
10
TEXT|0s
1
""
-
+
1
noteId
1
-
+
type
-
+
noteId
1
sqlite_autoindex_notes_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
-
+
3
INT|0s
-
+
4
INTEGER|0s
1
0
-
+
5
TEXT|0s
1
""
-
+
6
TEXT|0s
1
'1970-01-01T00:00:00.000Z'
-
+
1
name
1
-
+
name
1
sqlite_autoindex_options_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
1
""
-
+
4
TEXT|0s
1
-
+
5
INT|0s
-
+
1
branchId
1
-
+
branchId
1
sqlite_autoindex_recent_notes_1
-
+
1
TEXT|0s
1
-
+
2
TEXT|0s
1
-
- 3
- TEXT|0s
- 1
-
-
- 4
- TEXT|0s
- 1
-
-
- 5
- INT|0s
- 1
- 0
-
-
- 6
- TEXT|0s
- 1
-
-
- 7
- TEXT|0s
- 1
-
-
- 8
- INT|0s
- 1
-
-
- 9
- TEXT|0s
- 1
- ""
-
-
- 10
- int|0s
- 0
-
-
- 1
- relationId
-
- 1
-
-
- sourceNoteId
-
-
-
- targetNoteId
-
-
-
- relationId
- 1
- sqlite_autoindex_relations_1
-
-
- 1
- TEXT|0s
- 1
-
-
- 2
- TEXT|0s
- 1
-
-
+
1
sourceId
1
-
+
sourceId
1
sqlite_autoindex_source_ids_1
-
+
1
text|0s
-
+
2
text|0s
-
+
3
text|0s
-
+
4
integer|0s
-
+
5
text|0s
-
+
1
-
+
2
-
+
1
INTEGER|0s
1
1
-
+
2
TEXT|0s
1
-
+
3
TEXT|0s
1
-
+
4
TEXT|0s
1
-
+
5
TEXT|0s
1
-
+
entityName
entityId
1
-
+
syncDate
-
+
id
1
diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js
index 7e65d2d72..e36e6be66 100644
--- a/src/services/consistency_checks.js
+++ b/src/services/consistency_checks.js
@@ -3,7 +3,6 @@
const sql = require('./sql');
const sqlInit = require('./sql_init');
const log = require('./log');
-const utils = require('./utils');
const messagingService = require('./messaging');
const syncMutexService = require('./sync_mutex');
const cls = require('./cls');
diff --git a/src/services/note_cache.js b/src/services/note_cache.js
index 5b5717b1a..ecd8f6e75 100644
--- a/src/services/note_cache.js
+++ b/src/services/note_cache.js
@@ -11,7 +11,7 @@ let protectedNoteTitles;
let noteIds;
let childParentToBranchId = {};
const childToParent = {};
-const archived = {};
+let archived = {};
// key is 'childNoteId-parentNoteId' as a replacement for branchId which we don't use here
let prefixes = {};
@@ -30,11 +30,7 @@ async function load() {
childParentToBranchId[`${rel.noteId}-${rel.parentNoteId}`] = rel.branchId;
}
- const hiddenLabels = await sql.getColumn(`SELECT noteId FROM attributes WHERE type = 'label' AND isDeleted = 0 AND name = 'archived'`);
-
- for (const noteId of hiddenLabels) {
- archived[noteId] = true;
- }
+ archived = await sql.getMap(`SELECT noteId, isInheritable FROM attributes WHERE isDeleted = 0 AND type = 'label' AND name = 'archived'`);
loaded = true;
}
@@ -54,7 +50,8 @@ function findNotes(query) {
}
for (const noteId of noteIds) {
- if (archived[noteId]) {
+ // for leaf note it doesn't matter if "archived" label inheritable or not
+ if (noteId in archived) {
continue;
}
@@ -64,7 +61,8 @@ function findNotes(query) {
}
for (const parentNoteId of parents) {
- if (archived[parentNoteId]) {
+ // for parent note archived needs to be inheritable
+ if (archived[parentNoteId] === 1) {
continue;
}
@@ -120,7 +118,8 @@ function search(noteId, tokens, path, results) {
return;
}
- if (parentNoteId === 'root' || archived[parentNoteId]) {
+ // archived must be inheritable
+ if (parentNoteId === 'root' || archived[parentNoteId] === 1) {
continue;
}
@@ -198,7 +197,8 @@ function getSomePath(noteId, path) {
}
for (const parentNoteId of parents) {
- if (archived[parentNoteId]) {
+ // archived applies here only if inheritable
+ if (archived[parentNoteId] === 1) {
continue;
}
@@ -273,8 +273,10 @@ eventService.subscribe(eventService.ENTITY_CHANGED, async ({entityName, entityId
const hideLabel = await repository.getEntity(`SELECT * FROM attributes WHERE isDeleted = 0 AND type = 'label'
AND name = 'archived' AND noteId = ?`, [attribute.noteId]);
+ console.log(hideLabel);
+
if (hideLabel) {
- archived[attribute.noteId] = true;
+ archived[attribute.noteId] = hideLabel.isInheritable ? 1 : 0;
}
else {
delete archived[attribute.noteId];
diff --git a/src/views/index.ejs b/src/views/index.ejs
index 928d3f7ed..87adfe7d9 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -308,6 +308,8 @@
+
+