feat(network): add local network auto-switch feature (#1334)

This commit is contained in:
Fredrik Burmester
2026-01-11 13:08:14 +01:00
committed by GitHub
parent ac9ac5d423
commit 467bea7192
17 changed files with 823 additions and 70 deletions

View File

@@ -34,6 +34,15 @@ export interface SavedServerAccount {
savedAt: number;
}
/**
* Local network configuration for automatic URL switching.
*/
export interface LocalNetworkConfig {
localUrl: string;
homeWifiSSIDs: string[];
enabled: boolean;
}
/**
* Server with multiple saved accounts.
*/
@@ -41,6 +50,7 @@ export interface SavedServer {
address: string;
name?: string;
accounts: SavedServerAccount[];
localNetworkConfig?: LocalNetworkConfig;
}
/**
@@ -345,6 +355,37 @@ export function addServerToList(serverUrl: string, serverName?: string): void {
storage.set("previousServers", JSON.stringify(updatedServers));
}
/**
* Update local network configuration for a server.
*/
export function updateServerLocalConfig(
serverUrl: string,
config: LocalNetworkConfig | undefined,
): void {
const servers = getPreviousServers();
const updatedServers = servers.map((server) => {
if (server.address === serverUrl) {
return {
...server,
localNetworkConfig: config,
};
}
return server;
});
storage.set("previousServers", JSON.stringify(updatedServers));
}
/**
* Get local network configuration for a server.
*/
export function getServerLocalConfig(
serverUrl: string,
): LocalNetworkConfig | undefined {
const servers = getPreviousServers();
const server = servers.find((s) => s.address === serverUrl);
return server?.localNetworkConfig;
}
/**
* Migrate from legacy single-account format to multi-account format.
* Should be called on app startup.