Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: fix jumplist item activation when app is running

Abdullah Atta94c40b3444d2
diff --git a/apps/desktop/src/cli.ts b/apps/desktop/src/cli.ts
index 5d10d8f30..655b21521 100644
--- a/apps/desktop/src/cli.ts
+++ b/apps/desktop/src/cli.ts
@@ -27,19 +27,23 @@ export type CLIOptions = {
hidden: boolean;
};
-export async function parseArguments(): Promise<CLIOptions> {
+export async function parseArguments(argv: string[]): Promise<CLIOptions> {
const result: CLIOptions = {
note: false,
notebook: false,
reminder: false,
hidden: false
};
- const { hidden } = await yargs(hideBin(process.argv))
+ const { hidden } = await yargs(hideBin(argv))
.boolean("hidden")
+ // have to account for this flag added on Windows when launching
+ // via Jumplist
+ .boolean("allow-file-access-from-files")
.command("new", "Create a new item", (yargs) => {
return yargs
.command("note", "Create a new note", {}, () => {
result.note = true;
+ console.log("HERE!");
})
.command("notebook", "Create a new notebook", {}, () => {
result.notebook = true;
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index c02c836cb..add7619c2 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -34,6 +34,7 @@ import { router, api } from "./api";
import { config } from "./utils/config";
import path from "path";
import { bringToFront } from "./utils/bring-to-front";
+import { bridge } from "./api/bridge";
// only run a single instance
if (!MAC_APP_STORE && !app.requestSingleInstanceLock()) {
@@ -63,7 +64,7 @@ process.on("unhandledRejection", (reason) => {
app.commandLine.appendSwitch("lang", "en-US");
async function createWindow() {
- const cliOptions = await parseArguments();
+ const cliOptions = await parseArguments(process.argv);
setTheme(getTheme());
const mainWindowState = new WindowState({});
@@ -146,8 +147,12 @@ app.once("window-all-closed", () => {
}
});
-app.on("second-instance", () => {
+app.on("second-instance", async (_ev, argv) => {
if (!globalThis.window) return;
+ const cliOptions = await parseArguments(argv);
+ if (cliOptions.note) bridge.onCreateItem("note");
+ if (cliOptions.notebook) bridge.onCreateItem("notebook");
+ if (cliOptions.reminder) bridge.onCreateItem("reminder");
bringToFront();
});