mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-03-19 07:46:24 +00:00
feat(network): add local network auto-switch feature (#1334)
This commit is contained in:
committed by
GitHub
parent
ac9ac5d423
commit
467bea7192
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user