Skip to content

Build your personal knowledge base with Trilium Notes

server-ts: Address some review comments

Elian Dorand4c8d24d5022
diff --git a/src/services/search/search_result.ts b/src/services/search/search_result.ts
index cd4e31e7a0..cf651d58ed 100644
--- a/src/services/search/search_result.ts
+++ b/src/services/search/search_result.ts
@@ -51,9 +51,7 @@ class SearchResult {
addScoreForStrings(tokens: string[], str: string, factor: number) {
const chunks = str.toLowerCase().split(" ");
- if (!this.score) {
- this.score = 0;
- }
+ this.score = 0;
for (const chunk of chunks) {
for (const token of tokens) {
diff --git a/src/services/search/value_extractor.ts b/src/services/search/value_extractor.ts
index a32eb5f6d1..4f2466f111 100644
--- a/src/services/search/value_extractor.ts
+++ b/src/services/search/value_extractor.ts
@@ -113,7 +113,7 @@ class ValueExtractor {
i++;
const attr = cursor.getAttributeCaseInsensitive('relation', cur());
- cursor = (attr ? attr.targetNote || null : null);
+ cursor = attr?.targetNote || null;
}
else if (cur() === 'parents') {
cursor = cursor.parents[0];
diff --git a/src/services/tray.ts b/src/services/tray.ts
index 78e8645cdf..48a8ebaae3 100644
--- a/src/services/tray.ts
+++ b/src/services/tray.ts
@@ -3,11 +3,7 @@ import path = require('path');
import windowService = require('./window');
import optionService = require('./options');
-const UPDATE_TRAY_EVENTS = [
- 'minimize', 'maximize', 'show', 'hide'
-] as const;
-
-let tray: Tray | null = null;
+let tray: Tray;
// `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
// is minimized
let isVisible = true;
@@ -42,14 +38,15 @@ const registerVisibilityListener = () => {
// They need to be registered before the tray updater is registered
mainWindow.on('show', () => {
isVisible = true;
+ updateTrayMenu();
});
mainWindow.on('hide', () => {
isVisible = false;
+ updateTrayMenu();
});
- UPDATE_TRAY_EVENTS.forEach((eventName) => {
- mainWindow.on(eventName as any, updateTrayMenu)
- });
+ mainWindow.on("minimize", updateTrayMenu);
+ mainWindow.on("maximize", updateTrayMenu);
}
const updateTrayMenu = () => {