Skip to content

Build your personal knowledge base with Trilium Notes

set search note title correctly during creation

zadam7572ee284b36
diff --git a/package-lock.json b/package-lock.json
index 3cd1273b5b..08f17d8c5c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1263,9 +1263,9 @@
}
},
"async-mutex": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.0.tgz",
- "integrity": "sha512-6VIpUM7s37EMXvnO3TvujgaS6gx4yJby13BhxovMYSap7nrbS0gJ1UzGcjD+HElNSdTz/+IlAIqj7H48N0ZlyQ==",
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.1.tgz",
+ "integrity": "sha512-vRfQwcqBnJTLzVQo72Sf7KIUbcSUP5hNchx6udI1U6LuPQpfePgdjJzlCe76yFZ8pxlLjn9lwcl/Ya0TSOv0Tw==",
"requires": {
"tslib": "^2.1.0"
},
@@ -1769,9 +1769,9 @@
"dev": true
},
"caniuse-lite": {
- "version": "1.0.30001187",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001187.tgz",
- "integrity": "sha512-w7/EP1JRZ9552CyrThUnay2RkZ1DXxKe/Q2swTC4+LElLh9RRYrL1Z+27LlakB8kzY0fSmHw9mc7XYDUKAKWMA==",
+ "version": "1.0.30001191",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001191.tgz",
+ "integrity": "sha512-xJJqzyd+7GCJXkcoBiQ1GuxEiOBCLQ0aVW9HMekifZsAVGdj5eJ4mFB9fEhSHipq9IOk/QXFJUiIr9lZT+EsGw==",
"dev": true
},
"caseless": {
@@ -3252,9 +3252,9 @@
}
},
"electron-to-chromium": {
- "version": "1.3.667",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.667.tgz",
- "integrity": "sha512-Ot1pPtAVb5nd7jeVF651zmfLFilRVFomlDzwXmdlWe5jyzOGa6mVsQ06XnAurT7wWfg5VEIY+LopbAdD/bpo5w==",
+ "version": "1.3.673",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.673.tgz",
+ "integrity": "sha512-ms+QR2ckfrrpEAjXweLx6kNCbpAl66DcW//3BZD4BV5KhUgr0RZRce1ON/9J3QyA3JO28nzgb5Xv8DnPr05ILg==",
"dev": true
},
"electron-window-state": {
@@ -3346,9 +3346,9 @@
}
},
"es-module-lexer": {
- "version": "0.3.26",
- "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.3.26.tgz",
- "integrity": "sha512-Va0Q/xqtrss45hWzP8CZJwzGSZJjDM5/MJRE3IXXnUCcVLElR9BRaE9F62BopysASyc4nM3uwhSW7FFB9nlWAA==",
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.4.0.tgz",
+ "integrity": "sha512-iuEGihqqhKWFgh72Q/Jtch7V2t/ft8w8IPP2aEN8ArYKO+IWyo6hsi96hCdgyeEDQIV3InhYQ9BlwUFPGXrbEQ==",
"dev": true
},
"es6-error": {
@@ -5471,9 +5471,9 @@
}
},
"node-releases": {
- "version": "1.1.70",
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.70.tgz",
- "integrity": "sha512-Slf2s69+2/uAD79pVVQo8uSiC34+g8GWY8UH2Qtqv34ZfhYrxpYpfzs9Js9d6O0mbDmALuxaTlplnBTnSELcrw==",
+ "version": "1.1.71",
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz",
+ "integrity": "sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==",
"dev": true
},
"noop-logger": {
@@ -7662,9 +7662,9 @@
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w=="
},
"webpack": {
- "version": "5.23.0",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.23.0.tgz",
- "integrity": "sha512-RC6dwDuRxiU75F8XC4H08NtzUrMfufw5LDnO8dTtaKU2+fszEdySCgZhNwSBBn516iNaJbQI7T7OPHIgCwcJmg==",
+ "version": "5.24.2",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.24.2.tgz",
+ "integrity": "sha512-uxxKYEY4kMNjP+D2Y+8aw5Vd7ar4pMuKCNemxV26ysr1nk0YDiQTylg9U3VZIdkmI0YHa0uC8ABxL+uGxGWWJg==",
"dev": true,
"requires": {
"@types/eslint-scope": "^3.7.0",
@@ -7676,7 +7676,7 @@
"browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.7.0",
- "es-module-lexer": "^0.3.26",
+ "es-module-lexer": "^0.4.0",
"eslint-scope": "^5.1.1",
"events": "^3.2.0",
"glob-to-regexp": "^0.4.1",
diff --git a/package.json b/package.json
index a7734a39c4..71ad98e175 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"test-all": "npm run test && npm run test-es6"
},
"dependencies": {
- "async-mutex": "0.3.0",
+ "async-mutex": "0.3.1",
"axios": "0.21.1",
"better-sqlite3": "7.1.2",
"body-parser": "1.19.0",
@@ -87,7 +87,7 @@
"jsdoc": "3.6.6",
"lorem-ipsum": "2.0.3",
"rcedit": "3.0.0",
- "webpack": "5.23.0",
+ "webpack": "5.24.2",
"webpack-cli": "4.5.0"
},
"optionalDependencies": {
diff --git a/src/entities/note.js b/src/entities/note.js
index 5100c1e5a2..0abd734331 100644
--- a/src/entities/note.js
+++ b/src/entities/note.js
@@ -681,7 +681,7 @@ class Note extends Entity {
* Update's given relation's value or creates it if it doesn't exist
*
* @param {string} name - relation name
- * @param {string} [value] - relation value (noteId)
+ * @param {string} value - relation value (noteId)
*/
setRelation(name, value) { return this.setAttribute(RELATION, name, value); }
diff --git a/src/public/app/services/date_notes.js b/src/public/app/services/date_notes.js
index 297afb5d5e..e7906c5b05 100644
--- a/src/public/app/services/date_notes.js
+++ b/src/public/app/services/date_notes.js
@@ -52,16 +52,7 @@ async function createSqlConsole() {
/** @return {NoteShort} */
async function createSearchNote(opts = {}) {
- const note = await server.post('search-note');
-
- const attrsToUpdate = [
- opts.ancestorNoteId ? { type: 'relation', name: 'ancestor', value: opts.ancestorNoteId } : undefined,
- { type: 'label', name: 'searchString', value: opts.searchString }
- ].filter(attr => !!attr);
-
- if (attrsToUpdate.length > 0) {
- await server.put(`notes/${note.noteId}/attributes`, attrsToUpdate);
- }
+ const note = await server.post('search-note', opts);
await ws.waitForMaxKnownEntityChangeId();
diff --git a/src/routes/api/date_notes.js b/src/routes/api/date_notes.js
index 413d20f836..72e8cc2fd5 100644
--- a/src/routes/api/date_notes.js
+++ b/src/routes/api/date_notes.js
@@ -59,7 +59,10 @@ function createSqlConsole() {
return note;
}
-function createSearchNote() {
+function createSearchNote(req) {
+ const params = req.body;
+ const searchString = params.searchString || "";
+
const today = dateUtils.localNowDate();
const searchHome =
@@ -68,12 +71,18 @@ function createSearchNote() {
const {note} = noteService.createNewNote({
parentNoteId: searchHome.noteId,
- title: 'Search: ',
+ title: 'Search: ' + searchString,
content: "",
type: 'search',
mime: 'application/json'
});
+ note.setLabel('searchString', searchString);
+
+ if (params.ancestorNoteId) {
+ note.setRelation('ancestor', params.ancestorNoteId);
+ }
+
return note;
}