server-ts: Address some review comments

This commit is contained in:
Elian Doran 2024-04-02 23:39:45 +03:00
parent a420129631
commit d4c8d24d50
No known key found for this signature in database
3 changed files with 7 additions and 12 deletions

View File

@ -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) {

View File

@ -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];

View File

@ -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 = () => {