share improvements/cleanup

This commit is contained in:
zadam
2021-12-23 12:54:21 +01:00
parent 94111c464b
commit 972f2f40bf
4 changed files with 30 additions and 169 deletions

View File

@@ -34,15 +34,28 @@ function load() {
const noteIdStr = noteIds.map(noteId => `'${noteId}'`).join(",");
for (const row of sql.getRawRows(`SELECT noteId, title, type, mime, utcDateModified FROM notes WHERE isDeleted = 0 AND noteId IN (${noteIdStr})`)) {
const rawNoteRows = sql.getRawRows(`
SELECT noteId, title, type, mime, utcDateModified
FROM notes
WHERE isDeleted = 0
AND noteId IN (${noteIdStr})`);
for (const row of rawNoteRows) {
new Note(row);
}
for (const row of sql.getRawRows(`SELECT branchId, noteId, parentNoteId, prefix, isExpanded, utcDateModified FROM branches WHERE isDeleted = 0 AND parentNoteId IN (${noteIdStr}) ORDER BY notePosition`)) {
const rawBranchRows = sql.getRawRows(`
SELECT branchId, noteId, parentNoteId, prefix, isExpanded, utcDateModified
FROM branches
WHERE isDeleted = 0
AND parentNoteId IN (${noteIdStr})
ORDER BY notePosition`);
for (const row of rawBranchRows) {
new Branch(row);
}
const attributes = sql.getRawRows(`
const rawAttributeRows = sql.getRawRows(`
SELECT attributeId, noteId, type, name, value, isInheritable, position, utcDateModified
FROM attributes
WHERE isDeleted = 0
@@ -52,13 +65,13 @@ function load() {
OR (type = 'relation' AND name IN ('imageLink', 'template', 'shareCss'))
)`, []);
for (const row of attributes) {
for (const row of rawAttributeRows) {
new Attribute(row);
}
shaca.loaded = true;
log.info(`Shaca load took ${Date.now() - start}ms`);
log.info(`Shaca loaded ${rawNoteRows.length} notes, ${rawBranchRows.length} branches, ${rawAttributeRows.length} attributes took ${Date.now() - start}ms`);
}
function ensureLoad() {