Files
HealthLog/src/lib/account-name.ts
T
Marc-André Bombeck 1c4bcce6c7 fix(ui): name the account by its display name
The dashboard greeting, the Insights greeting, the top bar and the
sidebar read the username, so a display name set on the profile card
reached the reports but none of the surfaces that address the account.
They now read one helper that returns the display name when set and
falls back to the username otherwise.

Refs #1309
2026-11-01 00:56:24 +01:00

14 lines
482 B
TypeScript

/**
* The name the app shows and addresses an account by: the display name when
* one is set, the username otherwise. Greetings, the top bar and the sidebar
* all read it here, so the display name edited on the profile card reaches
* every surface that names the account.
*/
export function accountName(user: {
username: string;
displayName?: string | null;
}): string {
const displayName = user.displayName?.trim();
return displayName ? displayName : user.username;
}