From 9cf691345f443ee6073b8c15622d04081e2b7f7d Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 25 Jan 2023 09:47:19 +0100 Subject: [PATCH] Desktop: Open Recent support --- desktop/src/index.ts | 7 ++++++- desktop/src/instance.ts | 11 ++++++++++- desktop/src/menu.ts | 8 ++++++++ website/CHANGELOG.md | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/desktop/src/index.ts b/desktop/src/index.ts index fe9ff93..6150b86 100644 --- a/desktop/src/index.ts +++ b/desktop/src/index.ts @@ -1,7 +1,7 @@ import { app, BrowserWindow, Menu } from "electron"; import { openFolder, openFolderPicker } from "./instance"; import { menu } from "./menu"; -import { getOpenWindows } from "./store"; +import { getOpenWindows, newWindowState } from "./store"; // This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack // plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on @@ -18,6 +18,7 @@ if (require("electron-squirrel-startup")) { require("update-electron-app")(); async function boot() { + console.log("Process args", process.argv); const openWindows = getOpenWindows(); if (openWindows.length === 0) { await openFolderPicker(); @@ -38,6 +39,10 @@ app.on("ready", () => { boot().catch(console.error); }); +app.on("open-file", (event, path) => { + openFolder(newWindowState(path)).catch(console.error); +}); + // Quit when all windows are closed, except on macOS. There, it's common // for applications and their menu bar to stay active until the user quits // explicitly with Cmd + Q. diff --git a/desktop/src/instance.ts b/desktop/src/instance.ts index f7e2d00..9f0dfbb 100644 --- a/desktop/src/instance.ts +++ b/desktop/src/instance.ts @@ -1,5 +1,13 @@ import { ChildProcessWithoutNullStreams, spawn } from "node:child_process"; -import { app, BrowserWindow, dialog, Menu, MenuItem, shell, nativeImage } from "electron"; +import { + app, + BrowserWindow, + dialog, + Menu, + MenuItem, + nativeImage, + shell, +} from "electron"; import portfinder from "portfinder"; import fetch from "node-fetch"; import { existsSync } from "node:fs"; @@ -55,6 +63,7 @@ async function folderPicker(): Promise { export async function openFolderPicker() { const folderPath = await folderPicker(); if (folderPath) { + app.addRecentDocument(folderPath); openFolder(newWindowState(folderPath)); } } diff --git a/desktop/src/menu.ts b/desktop/src/menu.ts index f462cdc..e9cac02 100644 --- a/desktop/src/menu.ts +++ b/desktop/src/menu.ts @@ -25,6 +25,14 @@ const template: MenuItemConstructorOptions[] = [ openFolderPicker(); }, }, + { + role: "recentDocuments", + submenu: [ + { + role: "clearRecentDocuments", + }, + ], + }, { type: "separator" }, { label: "Quit", diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index ec26774..3c2780e 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -5,6 +5,8 @@ release. ## Next * Syntax highlighting for a bunch of new languages: PgSQL, Rust, CSS, Python, Protobuf, Shell, Swift, toml, XML, JSON, C, C++, Java, C#, Scala, Kotlin, ObjectiveC, ObjectiveC++ and Dart * [[Vim]] support for VIMRC (see [[Vim]] documentation) +* Desktop: “Open Recent” menu to quickly reopen recently opened spaces. +* Sync bug fixes and better logging (in {[Show Logs]}) --- ## 0.2.9