feat(tv): new login design

This commit is contained in:
Fredrik Burmester
2026-01-31 11:49:15 +01:00
parent 85a74a9a6a
commit 1ec887c29e
6 changed files with 273 additions and 29 deletions

View File

@@ -0,0 +1,32 @@
/**
* Retrieves the profile image URL for a Jellyfin user.
*
* @param serverAddress - The Jellyfin server base URL.
* @param userId - The user's ID.
* @param primaryImageTag - The user's primary image tag (required for the image to exist).
* @param width - The desired image width (default: 280).
* @returns The image URL or null if no image tag is provided.
*/
export const getUserImageUrl = ({
serverAddress,
userId,
primaryImageTag,
width = 280,
}: {
serverAddress: string;
userId: string;
primaryImageTag?: string | null;
width?: number;
}): string | null => {
if (!primaryImageTag) {
return null;
}
const params = new URLSearchParams({
tag: primaryImageTag,
quality: "90",
width: String(width),
});
return `${serverAddress}/Users/${userId}/Images/Primary?${params.toString()}`;
};

View File

@@ -22,6 +22,7 @@ export interface ServerCredential {
savedAt: number;
securityType: AccountSecurityType;
pinHash?: string;
primaryImageTag?: string;
}
/**
@@ -32,6 +33,7 @@ export interface SavedServerAccount {
username: string;
securityType: AccountSecurityType;
savedAt: number;
primaryImageTag?: string;
}
/**
@@ -131,6 +133,7 @@ export async function saveAccountCredential(
username: credential.username,
securityType: credential.securityType,
savedAt: credential.savedAt,
primaryImageTag: credential.primaryImageTag,
});
}
@@ -224,7 +227,7 @@ export async function clearAllCredentials(): Promise<void> {
/**
* Add or update an account in a server's accounts list.
*/
function addAccountToServer(
export function addAccountToServer(
serverUrl: string,
serverName: string,
account: SavedServerAccount,
@@ -475,19 +478,32 @@ export async function migrateToMultiAccount(): Promise<void> {
}
/**
* Update account's token after successful login.
* Update account's token and optionally other fields after successful login.
*/
export async function updateAccountToken(
serverUrl: string,
userId: string,
newToken: string,
primaryImageTag?: string,
): Promise<void> {
const credential = await getAccountCredential(serverUrl, userId);
if (credential) {
credential.token = newToken;
credential.savedAt = Date.now();
if (primaryImageTag !== undefined) {
credential.primaryImageTag = primaryImageTag;
}
const key = credentialKey(serverUrl, userId);
await SecureStore.setItemAsync(key, JSON.stringify(credential));
// Also update the account info in the server list
addAccountToServer(serverUrl, credential.serverName, {
userId: credential.userId,
username: credential.username,
securityType: credential.securityType,
savedAt: credential.savedAt,
primaryImageTag: credential.primaryImageTag,
});
}
}