refactor(desktop): extract instance-URL helpers to instanceUrl.ts

Pure mechanical extraction — no behavior change. Enables recovery.ts
to share these helpers without a circular import on main.ts.
This commit is contained in:
Jannis Braun
2026-05-03 03:58:00 +02:00
parent 3dc3043faf
commit dcbae46e0e
2 changed files with 38 additions and 31 deletions
+32
View File
@@ -0,0 +1,32 @@
import { app } from 'electron';
import path from 'path';
import fs from 'fs';
export function getInstanceUrlPath(): string {
return path.join(app.getPath('userData'), 'instance-url.json');
}
export function loadInstanceUrl(): string | null {
try {
const data = JSON.parse(fs.readFileSync(getInstanceUrlPath(), 'utf-8'));
return typeof data.url === 'string' ? data.url : null;
} catch {
return null;
}
}
export function saveInstanceUrl(url: string): void {
fs.writeFileSync(getInstanceUrlPath(), JSON.stringify({ url }));
}
export function clearInstanceUrl(): void {
try {
fs.unlinkSync(getInstanceUrlPath());
} catch {
// File may not exist — ignore
}
}
export function getPickerPath(): string {
return path.join(__dirname, '..', 'resources', 'instance-picker.html');
}