feat(tray): add option to create new note

This commit is contained in:
Elian Doran 2025-02-01 02:08:19 +02:00
parent 9e0d002704
commit 4b1cbca76d
No known key found for this signature in database

View File

@ -3,6 +3,7 @@ import path from "path";
import windowService from "./window.js"; import windowService from "./window.js";
import optionService from "./options.js"; import optionService from "./options.js";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
import type { KeyboardActionNames } from "./keyboard_actions_interface.js";
let tray: Tray; let tray: Tray;
// `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window // `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
@ -53,7 +54,17 @@ function updateTrayMenu() {
return; return;
} }
function triggerKeyboardAction(actionName: KeyboardActionNames) {
mainWindow?.webContents.send("globalShortcut", actionName);
}
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
{
label: "New Note",
type: "normal",
click: () => triggerKeyboardAction("createNoteIntoInbox")
},
{ type: "separator" },
{ {
label: isVisible ? "Hide" : "Show", label: isVisible ? "Hide" : "Show",
type: "normal", type: "normal",
@ -66,9 +77,7 @@ function updateTrayMenu() {
} }
} }
}, },
{ { type: "separator" },
type: "separator"
},
{ {
label: "Quit", label: "Quit",
type: "normal", type: "normal",