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
|
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
|
### Pulling in Stoat's assets
|
||||||
|
|
||||||
If you want to pull in Stoat brand assets after pulling, run the following:
|
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.nodejs.pkgs.pnpm
|
pkgs.nodejs.pkgs.pnpm
|
||||||
|
|
||||||
|
# Electron
|
||||||
|
(pkgs.writeShellScriptBin "electron-nix" ''
|
||||||
|
exec ${pkgs.electron}/bin/electron "$@"
|
||||||
|
'')
|
||||||
|
|
||||||
# build target: zip
|
# build target: zip
|
||||||
pkgs.zip
|
pkgs.zip
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "stoat-desktop",
|
"name": "stoat-desktop",
|
||||||
"productName": "stoat-desktop",
|
"productName": "stoat-desktop",
|
||||||
"version": "1.1.9",
|
"version": "1.1.10",
|
||||||
"main": ".vite/build/main.js",
|
"main": ".vite/build/main.js",
|
||||||
"repository": "stoatchat/desktop",
|
"repository": "stoatchat/desktop",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
"publish": "electron-forge publish",
|
"publish": "electron-forge publish",
|
||||||
"lint": "eslint --ext .ts,.tsx .",
|
"lint": "eslint --ext .ts,.tsx .",
|
||||||
"install:flatpak": "flatpak --user install out/make/flatpak/x86_64/chat.stoat.stoat-desktop_stable_x86_64.flatpak",
|
"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": [],
|
"keywords": [],
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
+30
-3
@@ -66,6 +66,18 @@ const store = new Store({
|
|||||||
* Shim for `electron-store` because typings are broken
|
* Shim for `electron-store` because typings are broken
|
||||||
*/
|
*/
|
||||||
class Config {
|
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() {
|
get firstLaunch() {
|
||||||
return (store as never as { get(k: string): boolean }).get("firstLaunch");
|
return (store as never as { get(k: string): boolean }).get("firstLaunch");
|
||||||
}
|
}
|
||||||
@@ -75,6 +87,8 @@ class Config {
|
|||||||
"firstLaunch",
|
"firstLaunch",
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
get customFrame() {
|
get customFrame() {
|
||||||
@@ -86,6 +100,8 @@ class Config {
|
|||||||
"customFrame",
|
"customFrame",
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
get minimiseToTray() {
|
get minimiseToTray() {
|
||||||
@@ -99,6 +115,8 @@ class Config {
|
|||||||
"minimiseToTray",
|
"minimiseToTray",
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
get spellchecker() {
|
get spellchecker() {
|
||||||
@@ -112,6 +130,8 @@ class Config {
|
|||||||
"spellchecker",
|
"spellchecker",
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
get hardwareAcceleration() {
|
get hardwareAcceleration() {
|
||||||
@@ -125,6 +145,8 @@ class Config {
|
|||||||
"hardwareAcceleration",
|
"hardwareAcceleration",
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
get discordRpc() {
|
get discordRpc() {
|
||||||
@@ -142,6 +164,8 @@ class Config {
|
|||||||
"discordRpc",
|
"discordRpc",
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
get windowState() {
|
get windowState() {
|
||||||
@@ -156,13 +180,16 @@ class Config {
|
|||||||
set(k: string, value: DesktopConfig["windowState"]): void;
|
set(k: string, value: DesktopConfig["windowState"]): void;
|
||||||
}
|
}
|
||||||
).set("windowState", value);
|
).set("windowState", value);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config = new Config();
|
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(
|
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();
|
updateTrayMenu();
|
||||||
tray.setToolTip("Stoat for Desktop");
|
tray.setToolTip("Stoat for Desktop");
|
||||||
tray.setImage(trayIcon);
|
tray.setImage(trayIcon);
|
||||||
|
tray.on("click", () => {
|
||||||
|
mainWindow.show();
|
||||||
|
mainWindow.focus();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateTrayMenu() {
|
export function updateTrayMenu() {
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ export function createMainWindow() {
|
|||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
minWidth: 300,
|
minWidth: 300,
|
||||||
minHeight: 300,
|
minHeight: 300,
|
||||||
width: 1100,
|
width: 1280,
|
||||||
height: 600,
|
height: 720,
|
||||||
backgroundColor: "#191919",
|
backgroundColor: "#191919",
|
||||||
frame: !config.customFrame,
|
frame: !config.customFrame,
|
||||||
icon: windowIcon,
|
icon: windowIcon,
|
||||||
@@ -54,6 +54,9 @@ export function createMainWindow() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// hide the options
|
||||||
|
mainWindow.setMenu(null);
|
||||||
|
|
||||||
// maximise the window if it was maximised before
|
// maximise the window if it was maximised before
|
||||||
if (config.windowState.isMaximised) {
|
if (config.windowState.isMaximised) {
|
||||||
mainWindow.maximize();
|
mainWindow.maximize();
|
||||||
@@ -101,6 +104,9 @@ export function createMainWindow() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// send the config
|
||||||
|
mainWindow.webContents.on("did-finish-load", () => config.sync());
|
||||||
|
|
||||||
// configure spellchecker context menu
|
// configure spellchecker context menu
|
||||||
mainWindow.webContents.on("context-menu", (_, params) => {
|
mainWindow.webContents.on("context-menu", (_, params) => {
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
|
|||||||
Reference in New Issue
Block a user