All files / service-web-theme/src account-model.ts

100% Statements 2/2
100% Branches 10/10
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                      113x 113x                        
import type { Locale } from './locale.ts';
 
/** Application adapters translate persisted account fields into this presentation shape. */
export interface ServiceAccountIdentity {
  handle: string;
  displayName: string;
  anonymous: boolean;
  avatarURL?: string;
}
 
export function resolveAccountIdentity(account: ServiceAccountIdentity, locale: Locale) {
  const guest = locale === 'ja' ? 'ゲスト' : 'guest';
  return {
    label: account.handle === '' ? account.displayName : `@${account.handle}`,
    ariaLabel:
      account.handle === ''
        ? account.displayName
        : locale === 'ja'
          ? `@${account.handle} のアカウント`
          : `Account of @${account.handle}`,
    title: account.anonymous ? `${account.displayName} (${guest})` : account.displayName,
    guest,
  };
}