feat(FN-3405): persist and restore desktop launch mode via IPC bridge
Merges five features: **Launch mode persistence** (FN-3405) — desktop now remembers and restores the user's preferred window mode across restarts via an IPC bridge; **Mailbox detail pane** (FN-3719/3720) — clicking messages in the Mail tab and Mailbox opens the detail pane and reply panel; **Remote Fusion-Task-Id: FN-3405
This commit is contained in:
@@ -18,6 +18,8 @@ export interface WindowState {
|
||||
isMaximized: boolean;
|
||||
}
|
||||
|
||||
export type DesktopLaunchMode = "choose" | "local" | "remote";
|
||||
|
||||
export const DEFAULT_WINDOW_STATE: WindowState = {
|
||||
width: 1280,
|
||||
height: 900,
|
||||
@@ -44,6 +46,10 @@ function getWindowStatePath(): string {
|
||||
return join(app.getPath("userData"), "window-state.json");
|
||||
}
|
||||
|
||||
function getDesktopLaunchModePath(): string {
|
||||
return join(app.getPath("userData"), "desktop-launch-mode.json");
|
||||
}
|
||||
|
||||
function isValidWindowState(value: unknown): value is WindowState {
|
||||
if (value === null || typeof value !== "object") {
|
||||
return false;
|
||||
@@ -160,6 +166,38 @@ export function setupAutoUpdater(mainWindow?: BrowserWindow): void {
|
||||
}
|
||||
}
|
||||
|
||||
function isValidDesktopLaunchMode(value: unknown): value is DesktopLaunchMode {
|
||||
return value === "choose" || value === "local" || value === "remote";
|
||||
}
|
||||
|
||||
export async function loadDesktopLaunchMode(): Promise<DesktopLaunchMode> {
|
||||
const launchModePath = getDesktopLaunchModePath();
|
||||
|
||||
try {
|
||||
const raw = await readFile(launchModePath, "utf-8");
|
||||
const parsed: unknown = JSON.parse(raw);
|
||||
|
||||
if (parsed && typeof parsed === "object" && "mode" in parsed) {
|
||||
const mode = (parsed as { mode?: unknown }).mode;
|
||||
if (isValidDesktopLaunchMode(mode)) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
return "choose";
|
||||
} catch {
|
||||
return "choose";
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveDesktopLaunchMode(mode: DesktopLaunchMode): Promise<void> {
|
||||
const launchModePath = getDesktopLaunchModePath();
|
||||
const tempPath = `${launchModePath}.tmp`;
|
||||
|
||||
await writeFile(tempPath, JSON.stringify({ mode }, null, 2), "utf-8");
|
||||
await rename(tempPath, launchModePath);
|
||||
}
|
||||
|
||||
export async function loadWindowState(): Promise<WindowState | null> {
|
||||
const statePath = getWindowStatePath();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user