Desktop: Open Recent support

pull/369/head
Zef Hemel 2023-01-25 09:47:19 +01:00
parent c56caac533
commit 9cf691345f
4 changed files with 26 additions and 2 deletions

View File

@ -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.

View File

@ -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<string> {
export async function openFolderPicker() {
const folderPath = await folderPicker();
if (folderPath) {
app.addRecentDocument(folderPath);
openFolder(newWindowState(folderPath));
}
}

View File

@ -25,6 +25,14 @@ const template: MenuItemConstructorOptions[] = [
openFolderPicker();
},
},
{
role: "recentDocuments",
submenu: [
{
role: "clearRecentDocuments",
},
],
},
{ type: "separator" },
{
label: "Quit",

View File

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