fix: correctly handle config updates
fix: synchronise updates to config with preload fix: send config on web contents load fix: hide menu when custom frame is off chore: add workarounds for developing on Nix chore: bump version to 1.1.10
This commit is contained in:
@@ -43,6 +43,27 @@ pnpm package
|
||||
pnpm make
|
||||
```
|
||||
|
||||
Various useful commands for development testing:
|
||||
|
||||
```bash
|
||||
# connect to the development server
|
||||
pnpm start -- --force-server http://localhost:5173
|
||||
|
||||
# test the flatpak (after `make`)
|
||||
pnpm install:flatpak
|
||||
pnpm run:flatpak
|
||||
# ... also connect to dev server like so:
|
||||
pnpm run:flatpak --force-server http://localhost:5173
|
||||
|
||||
# Nix-specific instructions for testing
|
||||
pnpm package
|
||||
pnpm run:nix
|
||||
# ... as before:
|
||||
pnpm run:nix --force-server=http://localhost:5173
|
||||
# a better solution would be telling
|
||||
# Electron Forge where system Electron is
|
||||
```
|
||||
|
||||
### Pulling in Stoat's assets
|
||||
|
||||
If you want to pull in Stoat brand assets after pulling, run the following:
|
||||
|
||||
@@ -12,6 +12,11 @@ pkgs.mkShell rec {
|
||||
pkgs.nodejs
|
||||
pkgs.nodejs.pkgs.pnpm
|
||||
|
||||
# Electron
|
||||
(pkgs.writeShellScriptBin "electron-nix" ''
|
||||
exec ${pkgs.electron}/bin/electron "$@"
|
||||
'')
|
||||
|
||||
# build target: zip
|
||||
pkgs.zip
|
||||
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "stoat-desktop",
|
||||
"productName": "stoat-desktop",
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.10",
|
||||
"main": ".vite/build/main.js",
|
||||
"repository": "stoatchat/desktop",
|
||||
"scripts": {
|
||||
@@ -11,7 +11,8 @@
|
||||
"publish": "electron-forge publish",
|
||||
"lint": "eslint --ext .ts,.tsx .",
|
||||
"install:flatpak": "flatpak --user install out/make/flatpak/x86_64/chat.stoat.stoat-desktop_stable_x86_64.flatpak",
|
||||
"run:flatpak": "flatpak run --socket=session-bus chat.stoat.stoat-desktop"
|
||||
"run:flatpak": "flatpak run --socket=session-bus chat.stoat.stoat-desktop",
|
||||
"run:nix": "/usr/bin/env electron-nix ."
|
||||
},
|
||||
"keywords": [],
|
||||
"author": {
|
||||
|
||||
+31
-4
@@ -66,6 +66,18 @@ const store = new Store({
|
||||
* Shim for `electron-store` because typings are broken
|
||||
*/
|
||||
class Config {
|
||||
sync() {
|
||||
mainWindow.webContents.send("config", {
|
||||
firstLaunch: this.firstLaunch,
|
||||
customFrame: this.customFrame,
|
||||
minimiseToTray: this.minimiseToTray,
|
||||
spellchecker: this.spellchecker,
|
||||
hardwareAcceleration: this.hardwareAcceleration,
|
||||
discordRpc: this.discordRpc,
|
||||
windowState: this.windowState,
|
||||
});
|
||||
}
|
||||
|
||||
get firstLaunch() {
|
||||
return (store as never as { get(k: string): boolean }).get("firstLaunch");
|
||||
}
|
||||
@@ -75,6 +87,8 @@ class Config {
|
||||
"firstLaunch",
|
||||
value,
|
||||
);
|
||||
|
||||
this.sync();
|
||||
}
|
||||
|
||||
get customFrame() {
|
||||
@@ -86,6 +100,8 @@ class Config {
|
||||
"customFrame",
|
||||
value,
|
||||
);
|
||||
|
||||
this.sync();
|
||||
}
|
||||
|
||||
get minimiseToTray() {
|
||||
@@ -99,6 +115,8 @@ class Config {
|
||||
"minimiseToTray",
|
||||
value,
|
||||
);
|
||||
|
||||
this.sync();
|
||||
}
|
||||
|
||||
get spellchecker() {
|
||||
@@ -112,6 +130,8 @@ class Config {
|
||||
"spellchecker",
|
||||
value,
|
||||
);
|
||||
|
||||
this.sync();
|
||||
}
|
||||
|
||||
get hardwareAcceleration() {
|
||||
@@ -125,6 +145,8 @@ class Config {
|
||||
"hardwareAcceleration",
|
||||
value,
|
||||
);
|
||||
|
||||
this.sync();
|
||||
}
|
||||
|
||||
get discordRpc() {
|
||||
@@ -142,6 +164,8 @@ class Config {
|
||||
"discordRpc",
|
||||
value,
|
||||
);
|
||||
|
||||
this.sync();
|
||||
}
|
||||
|
||||
get windowState() {
|
||||
@@ -156,13 +180,16 @@ class Config {
|
||||
set(k: string, value: DesktopConfig["windowState"]): void;
|
||||
}
|
||||
).set("windowState", value);
|
||||
|
||||
this.sync();
|
||||
}
|
||||
}
|
||||
|
||||
export const config = new Config();
|
||||
|
||||
ipcMain.on("config", (newConfig) =>
|
||||
ipcMain.on("config", (_, newConfig: Partial<DesktopConfig>) => {
|
||||
console.info("Received new configuration", newConfig);
|
||||
Object.entries(newConfig).forEach(
|
||||
([key, value]) => (config[key as keyof DesktopConfig] = value),
|
||||
),
|
||||
);
|
||||
([key, value]) => (config[key as keyof DesktopConfig] = value as never),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -18,6 +18,10 @@ export function initTray() {
|
||||
updateTrayMenu();
|
||||
tray.setToolTip("Stoat for Desktop");
|
||||
tray.setImage(trayIcon);
|
||||
tray.on("click", () => {
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
});
|
||||
}
|
||||
|
||||
export function updateTrayMenu() {
|
||||
|
||||
@@ -40,8 +40,8 @@ export function createMainWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
minWidth: 300,
|
||||
minHeight: 300,
|
||||
width: 1100,
|
||||
height: 600,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
backgroundColor: "#191919",
|
||||
frame: !config.customFrame,
|
||||
icon: windowIcon,
|
||||
@@ -54,6 +54,9 @@ export function createMainWindow() {
|
||||
},
|
||||
});
|
||||
|
||||
// hide the options
|
||||
mainWindow.setMenu(null);
|
||||
|
||||
// maximise the window if it was maximised before
|
||||
if (config.windowState.isMaximised) {
|
||||
mainWindow.maximize();
|
||||
@@ -101,6 +104,9 @@ export function createMainWindow() {
|
||||
}
|
||||
});
|
||||
|
||||
// send the config
|
||||
mainWindow.webContents.on("did-finish-load", () => config.sync());
|
||||
|
||||
// configure spellchecker context menu
|
||||
mainWindow.webContents.on("context-menu", (_, params) => {
|
||||
const menu = new Menu();
|
||||
|
||||
Reference in New Issue
Block a user