feat(tray): open today's journal note

This commit is contained in:
Elian Doran 2025-02-01 02:18:10 +02:00
parent 4b1cbca76d
commit 84edf0348f
No known key found for this signature in database
2 changed files with 12 additions and 0 deletions

View File

@ -48,6 +48,7 @@ if (utils.isElectron()) {
function initOnElectron() {
const electron: typeof Electron = utils.dynamicRequire("electron");
electron.ipcRenderer.on("globalShortcut", async (event, actionName) => appContext.triggerCommand(actionName));
electron.ipcRenderer.on("openInSameTab", async (event, noteId) => appContext.tabManager.openInSameTab(noteId));
const electronRemote: typeof ElectronRemote = utils.dynamicRequire("@electron/remote");
const currentWindow = electronRemote.getCurrentWindow();
const style = window.getComputedStyle(document.body);

View File

@ -4,6 +4,8 @@ import windowService from "./window.js";
import optionService from "./options.js";
import { fileURLToPath } from "url";
import type { KeyboardActionNames } from "./keyboard_actions_interface.js";
import date_notes from "./date_notes.js";
import type BNote from "../becca/entities/bnote.js";
let tray: Tray;
// `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
@ -58,12 +60,21 @@ function updateTrayMenu() {
mainWindow?.webContents.send("globalShortcut", actionName);
}
function openInSameTab(note: BNote) {
mainWindow?.webContents.send("openInSameTab", note.noteId);
}
const contextMenu = Menu.buildFromTemplate([
{
label: "New Note",
type: "normal",
click: () => triggerKeyboardAction("createNoteIntoInbox")
},
{
label: "Open today's journal note",
type: "normal",
click: () => openInSameTab(date_notes.getTodayNote())
},
{ type: "separator" },
{
label: isVisible ? "Hide" : "Show",