bug fixes

This commit is contained in:
zadam 2021-09-07 22:37:03 +02:00
parent 5cfd1c030d
commit 2b8c6e3dd0
5 changed files with 53 additions and 38 deletions

44
package-lock.json generated
View File

@ -1334,11 +1334,11 @@
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
}, },
"axios": { "axios": {
"version": "0.21.1", "version": "0.21.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.3.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", "integrity": "sha512-JtoZ3Ndke/+Iwt5n+BgSli/3idTvpt5OjKyoCmz4LX5+lPiY5l7C1colYezhlxThjNa/NhngCUWZSZFypIFuaA==",
"requires": { "requires": {
"follow-redirects": "^1.10.0" "follow-redirects": "^1.14.0"
} }
}, },
"bagpipe": { "bagpipe": {
@ -1365,9 +1365,9 @@
} }
}, },
"better-sqlite3": { "better-sqlite3": {
"version": "7.4.3", "version": "7.1.4",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-7.4.3.tgz", "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-7.1.4.tgz",
"integrity": "sha512-07bKjClZg/f4KMVRkzWtoIvazVPcF1gsvVKVIXlxwleC2DxuIhnra3KCMlUT1rFeRYXXckot2a46UciF2d9KLw==", "integrity": "sha512-9BvUSm8/xSyxZbnWpcRAwEZsfTK0196qi4592N5WoVMM3dAH9g0E3/colX0dxhGVSLcVfkiBUoCEBkFz8uvySw==",
"requires": { "requires": {
"bindings": "^1.5.0", "bindings": "^1.5.0",
"prebuild-install": "^6.0.1", "prebuild-install": "^6.0.1",
@ -1899,9 +1899,9 @@
"dev": true "dev": true
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001252", "version": "1.0.30001254",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001252.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001254.tgz",
"integrity": "sha512-I56jhWDGMtdILQORdusxBOH+Nl/KgQSdDmpJezYddnAkVOmnoU8zwjTV9xAjMIYxr0iPreEAVylCGcmHCjfaOw==", "integrity": "sha512-GxeHOvR0LFMYPmFGA+NiTOt9uwYDxB3h154tW2yBYwfz2EMX3i1IBgr6gmJGfU0K8KQsqPa5XqLD8zVdP5lUzA==",
"dev": true "dev": true
}, },
"caseless": { "caseless": {
@ -3573,9 +3573,9 @@
} }
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.827", "version": "1.3.830",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.827.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.830.tgz",
"integrity": "sha512-ye+4uQOY/jbjRutMcE/EmOcNwUeo1qo9aKL2tPyb09cU3lmxNeyDF4RWiemmkknW+p29h7dyDqy02higTxc9/A==", "integrity": "sha512-gBN7wNAxV5vl1430dG+XRcQhD4pIeYeak6p6rjdCtlz5wWNwDad8jwvphe5oi1chL5MV6RNRikfffBBiFuj+rQ==",
"dev": true "dev": true
}, },
"electron-window-state": { "electron-window-state": {
@ -4136,9 +4136,9 @@
} }
}, },
"follow-redirects": { "follow-redirects": {
"version": "1.13.1", "version": "1.14.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.3.tgz",
"integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==" "integrity": "sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw=="
}, },
"forever-agent": { "forever-agent": {
"version": "0.6.1", "version": "0.6.1",
@ -7573,9 +7573,9 @@
} }
}, },
"terser-webpack-plugin": { "terser-webpack-plugin": {
"version": "5.2.1", "version": "5.2.3",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.2.1.tgz", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.2.3.tgz",
"integrity": "sha512-mUAWsS2RDNL3rEr0ZTr7hm/R1DDxNwrED7Kf59F2rgFTfy+LrnciwA51MNWhGGQcqHnqvbPHgkW9LYr5HGBhfw==", "integrity": "sha512-eDbuaDlXhVaaoKuLD3DTNTozKqln6xOG6Us0SzlKG5tNlazG+/cdl8pm9qiF1Di89iWScTI0HcO+CDcf2dkXiw==",
"dev": true, "dev": true,
"requires": { "requires": {
"jest-worker": "^27.0.6", "jest-worker": "^27.0.6",
@ -8028,9 +8028,9 @@
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==" "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w=="
}, },
"webpack": { "webpack": {
"version": "5.51.2", "version": "5.52.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.51.2.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.52.0.tgz",
"integrity": "sha512-odydxP4WA3XYYzwSQUivPxywdzMlY42bbfxMwCaEtHb+i/N9uzKSHcLgWkXo/Gsa+4Zlzf3Jg0hEHn1FnZpk2Q==", "integrity": "sha512-yRZOat8jWGwBwHpco3uKQhVU7HYaNunZiJ4AkAVQkPCUGoZk/tiIXiwG+8HIy/F+qsiZvSOa+GLQOj3q5RKRYg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",

View File

@ -26,8 +26,8 @@
"dependencies": { "dependencies": {
"archiver": "5.3.0", "archiver": "5.3.0",
"async-mutex": "0.3.2", "async-mutex": "0.3.2",
"axios": "0.21.1", "axios": "0.21.4",
"better-sqlite3": "7.4.3", "better-sqlite3": "7.1.4",
"body-parser": "1.19.0", "body-parser": "1.19.0",
"chokidar": "3.5.2", "chokidar": "3.5.2",
"cls-hooked": "4.2.2", "cls-hooked": "4.2.2",
@ -90,7 +90,7 @@
"jsdoc": "3.6.7", "jsdoc": "3.6.7",
"lorem-ipsum": "2.0.3", "lorem-ipsum": "2.0.3",
"rcedit": "3.0.1", "rcedit": "3.0.1",
"webpack": "5.51.2", "webpack": "5.52.0",
"webpack-cli": "4.8.0" "webpack-cli": "4.8.0"
}, },
"optionalDependencies": { "optionalDependencies": {

View File

@ -86,6 +86,10 @@ function getNoteTitle(childNoteId, parentNoteId) {
} }
function getNoteTitleArrayForPath(notePathArray) { function getNoteTitleArrayForPath(notePathArray) {
if (!notePathArray || !Array.isArray(notePathArray)) {
throw new Error(`${notePathArray} is not an array.`);
}
if (notePathArray.length === 1 && notePathArray[0] === cls.getHoistedNoteId()) { if (notePathArray.length === 1 && notePathArray[0] === cls.getHoistedNoteId()) {
return [getNoteTitle(cls.getHoistedNoteId())]; return [getNoteTitle(cls.getHoistedNoteId())];
} }
@ -131,12 +135,12 @@ function getSomePath(note, path = []) {
|| getSomePathInner(note, path, false); || getSomePathInner(note, path, false);
} }
function getSomePathInner(note, path, respectHoistng) { function getSomePathInner(note, path, respectHoisting) {
if (note.isRoot()) { if (note.isRoot()) {
path.push(note.noteId); path.push(note.noteId);
path.reverse(); path.reverse();
if (respectHoistng && !path.includes(cls.getHoistedNoteId())) { if (respectHoisting && !path.includes(cls.getHoistedNoteId())) {
return false; return false;
} }
@ -145,11 +149,13 @@ function getSomePathInner(note, path, respectHoistng) {
const parents = note.parents; const parents = note.parents;
if (parents.length === 0) { if (parents.length === 0) {
console.log(`Note ${note.noteId} - "${note.title}" has no parents.`);
return false; return false;
} }
for (const parentNote of parents) { for (const parentNote of parents) {
const retPath = getSomePathInner(parentNote, path.concat([note.noteId]), respectHoistng); const retPath = getSomePathInner(parentNote, path.concat([note.noteId]), respectHoisting);
if (retPath) { if (retPath) {
return retPath; return retPath;

View File

@ -7,15 +7,18 @@ const becca = require("../becca/becca");
let maxEntityChangeId = 0; let maxEntityChangeId = 0;
function addEntityChange(entityChange) { function addEntityChange(origEntityChange) {
entityChange.sourceId = entityChange.sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId(); const ec = {...origEntityChange};
entityChange.isSynced = entityChange.isSynced ? 1 : 0;
entityChange.isErased = entityChange.isErased ? 1 : 0;
entityChange.id = sql.replace("entity_changes", entityChange);
maxEntityChangeId = Math.max(maxEntityChangeId, entityChange.id); delete ec.id;
ec.sourceId = ec.sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId();
ec.isSynced = ec.isSynced ? 1 : 0;
ec.isErased = ec.isErased ? 1 : 0;
ec.id = sql.replace("entity_changes", ec);
cls.addEntityChange(entityChange); maxEntityChangeId = Math.max(maxEntityChangeId, ec.id);
cls.addEntityChange(ec);
} }
function addNoteReorderingEntityChange(parentNoteId, sourceId) { function addNoteReorderingEntityChange(parentNoteId, sourceId) {

View File

@ -83,9 +83,15 @@ function findResultsWithExpression(expression, searchContext) {
const noteSet = expression.execute(allNoteSet, executionContext); const noteSet = expression.execute(allNoteSet, executionContext);
const searchResults = noteSet.notes const searchResults = noteSet.notes
.map(note => new SearchResult( .map(note => {
executionContext.noteIdToNotePath[note.noteId] || beccaService.getSomePath(note) const notePathArray = executionContext.noteIdToNotePath[note.noteId] || beccaService.getSomePath(note);
));
if (!notePathArray) {
throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`);
}
return new SearchResult(notePathArray);
});
for (const res of searchResults) { for (const res of searchResults) {
res.computeScore(searchContext.highlightedTokens); res.computeScore(searchContext.highlightedTokens);