Implement enhanced server switching with credential persistence and auto-login

Co-authored-by: retardgerman <78982850+retardgerman@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-09-05 18:14:44 +00:00
parent 17f7b42728
commit 214832f81c
4 changed files with 177 additions and 8 deletions

View File

@@ -8,6 +8,13 @@ import { ListItem } from "./list/ListItem";
interface Server {
address: string;
serverName?: string;
serverId?: string;
lastUsername?: string;
savedCredentials?: {
username: string;
password: string;
};
}
interface PreviousServersListProps {
@@ -26,6 +33,20 @@ export const PreviousServersList: React.FC<PreviousServersListProps> = ({
const { t } = useTranslation();
const getServerDisplayName = (server: Server) => {
if (server.serverName) {
return `${server.serverName}`;
}
return server.address;
};
const getServerSubtitle = (server: Server) => {
if (server.lastUsername) {
return `${server.address}${server.lastUsername}`;
}
return server.address;
};
if (!previousServers.length) return null;
return (
@@ -35,7 +56,9 @@ export const PreviousServersList: React.FC<PreviousServersListProps> = ({
<ListItem
key={s.address}
onPress={() => onServerSelect(s)}
title={s.address}
title={getServerDisplayName(s)}
subtitle={getServerSubtitle(s)}
icon={s.savedCredentials ? "key" : "server"}
showArrow
/>
))}

View File

@@ -10,6 +10,13 @@ import { ListItem } from "../list/ListItem";
interface Server {
address: string;
serverName?: string;
serverId?: string;
lastUsername?: string;
savedCredentials?: {
username: string;
password: string;
};
}
interface Props extends ViewProps {}
@@ -38,6 +45,23 @@ export const ServerSwitcher: React.FC<Props> = ({ ...props }) => {
}
};
const getServerDisplayName = (server: Server) => {
if (server.serverName) {
return `${server.serverName} (${server.address})`;
}
return server.address;
};
const getServerSubtitle = (server: Server) => {
if (server.lastUsername) {
const hasCredentials = !!server.savedCredentials;
return hasCredentials
? `${server.lastUsername} • Auto-login available`
: `Last user: ${server.lastUsername}`;
}
return undefined;
};
if (!previousServers.length) {
return (
<View {...props}>
@@ -55,7 +79,9 @@ export const ServerSwitcher: React.FC<Props> = ({ ...props }) => {
<ListItem
key={server.address}
onPress={() => handleServerSwitch(server)}
title={server.address}
title={getServerDisplayName(server)}
subtitle={getServerSubtitle(server)}
icon={server.savedCredentials ? "key" : "server"}
showArrow
disabled={switchingServer === server.address}
/>