diff --git a/CHANGELOG.md b/CHANGELOG.md index f027da8..cd885c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +### Added + +- The website uses your Google or Discord picture as your profile picture when you sign in with one of them. +- While the console is still sending images, the website shows how many have arrived (in the sync badge and on the profile), and they appear as they arrive. + +### Changed + +- Images the console has not sent yet show the placeholder instead of a broken image. + ### Security - The console's pairing QR code puts the code in the URL fragment (`/link#code=…`), which browsers never send, so the code no longer reaches the server or its logs. The website still accepts `/link?code=…` from older consoles. diff --git a/contract/api.ts b/contract/api.ts index d64df22..f6b84f1 100644 --- a/contract/api.ts +++ b/contract/api.ts @@ -57,6 +57,11 @@ export interface Trophy { iconUrl: string | null; } +export interface ImageSync { + total: number; + stored: number; +} + export interface EarnedTrophy { setId: string; setName: string; diff --git a/web/src/app/(app)/(profile)/_components/image-sync-banner.tsx b/web/src/app/(app)/(profile)/_components/image-sync-banner.tsx new file mode 100644 index 0000000..d844c20 --- /dev/null +++ b/web/src/app/(app)/(profile)/_components/image-sync-banner.tsx @@ -0,0 +1,21 @@ +import type { ImageSync } from '@openpsapp/contract/api'; +import { ImageIcon } from 'lucide-react'; +import { useTranslation } from 'react-i18next'; +import { Card } from '@/components/ui/card'; +import { Progress } from '@/components/ui/progress'; + +export function ImageSyncBanner({ images, className }: { images: ImageSync; className?: string }) { + const { t } = useTranslation(); + return ( + +
+ +
+

{t('images.title')}

+

{t('images.description', { stored: images.stored, total: images.total })}

+ +
+
+
+ ); +} diff --git a/web/src/app/(app)/(profile)/_components/profile-hero.tsx b/web/src/app/(app)/(profile)/_components/profile-hero.tsx index b5f88e3..33d10ed 100644 --- a/web/src/app/(app)/(profile)/_components/profile-hero.tsx +++ b/web/src/app/(app)/(profile)/_components/profile-hero.tsx @@ -1,9 +1,10 @@ import type { ReactNode } from 'react'; -import { Avatar, AvatarFallback } from '@/components/ui/avatar'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; export function ProfileHero({ name, initial, + avatarUrl, summary, summaryShort, heroUrl, @@ -11,6 +12,7 @@ export function ProfileHero({ }: { name: string; initial: string; + avatarUrl: string | null; summary: string; summaryShort: string; heroUrl: string | null; @@ -26,6 +28,7 @@ export function ProfileHero({
+ {avatarUrl && } {initial} diff --git a/web/src/app/(app)/(profile)/page.tsx b/web/src/app/(app)/(profile)/page.tsx index c6498be..29e3ec5 100644 --- a/web/src/app/(app)/(profile)/page.tsx +++ b/web/src/app/(app)/(profile)/page.tsx @@ -1,3 +1,4 @@ +import { useUser } from '@clerk/react'; import { formatDuration } from '@openpsapp/core'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -6,10 +7,12 @@ import { PageLoader } from '@/components/page-loader'; import { useDevices } from '@/hooks/use-devices'; import { useEarnedTrophies } from '@/hooks/use-earned-trophies'; import { useGames } from '@/hooks/use-games'; +import { useImageSync } from '@/hooks/use-image-sync'; import { useProfile } from '@/hooks/use-profile'; import { useTrophySets } from '@/hooks/use-trophy-sets'; import { paths } from '@/lib/links'; -import { describeSync } from '../_lib/sync-status'; +import { avatarUrl, describeSync, pendingImages } from '../_lib/sync-status'; +import { ImageSyncBanner } from './_components/image-sync-banner'; import { LatestTrophies } from './_components/latest-trophies'; import { MonthRecap } from './_components/month-recap'; import { PlatinumCard } from './_components/platinum-card'; @@ -29,6 +32,8 @@ export default function ProfilePage() { const sets = useTrophySets(); const earned = useEarnedTrophies(); const devices = useDevices(); + const images = pendingImages(useImageSync()); + const { user: account } = useUser(); const [expanded, setExpanded] = useState(false); const recap = useMonthRecap(earned.data ?? NO_ITEMS, games.data ?? NO_ITEMS, sets.data ?? NO_ITEMS); @@ -64,12 +69,14 @@ export default function ProfilePage() { } />
+ {images && }
- {initial} + diff --git a/web/src/app/(app)/_components/mobile-header.tsx b/web/src/app/(app)/_components/mobile-header.tsx index 4411f7d..c4ebf1c 100644 --- a/web/src/app/(app)/_components/mobile-header.tsx +++ b/web/src/app/(app)/_components/mobile-header.tsx @@ -4,17 +4,20 @@ import { useTranslation } from 'react-i18next'; import { Link } from 'react-router'; import { LogoMark } from '@/components/brand/logo'; import { Button } from '@/components/ui/button'; +import { UserAvatar } from './user-avatar'; export function MobileHeader({ homeTo, accountTo, initial, + avatarUrl, status, onSearch, }: { homeTo: string; accountTo: string; initial: string; + avatarUrl: string | null; status: ReactNode; onSearch: () => void; }) { @@ -31,9 +34,9 @@ export function MobileHeader({ - {initial} + ); diff --git a/web/src/app/(app)/_components/sync-badge.tsx b/web/src/app/(app)/_components/sync-badge.tsx index cd59c6e..3e17e20 100644 --- a/web/src/app/(app)/_components/sync-badge.tsx +++ b/web/src/app/(app)/_components/sync-badge.tsx @@ -1,12 +1,21 @@ +import type { ImageSync } from '@openpsapp/contract/api'; import { formatTimeAgo } from '@openpsapp/core'; import { cn } from 'cn'; import { useTranslation } from 'react-i18next'; import { Badge } from '@/components/ui/badge'; import type { SyncState } from '../_types/sync'; -export function SyncBadge({ sync, now }: { sync: SyncState; now: Date }) { +export function SyncBadge({ sync, images, now }: { sync: SyncState; images: ImageSync | null; now: Date }) { const { t, i18n } = useTranslation(); if (sync.kind === 'none') return null; + if (sync.kind === 'synced' && images) { + return ( + + + ); + } if (sync.kind === 'waiting') { return ( @@ -22,15 +31,28 @@ export function SyncBadge({ sync, now }: { sync: SyncState; now: Date }) { ); } -export function SyncPill({ sync, now, className }: { sync: SyncState; now: Date; className?: string }) { +export function SyncPill({ sync, images, now, className }: { sync: SyncState; images: ImageSync | null; now: Date; className?: string }) { const { t, i18n } = useTranslation(); if (sync.kind === 'none') return null; - const text = sync.kind === 'waiting' ? t('sync.waiting') : t('sync.short', { ago: formatTimeAgo(sync.at, now, i18n.language) }); + const sending = sync.kind === 'synced' && images; + const text = + sync.kind === 'waiting' + ? t('sync.waiting') + : sending + ? t('images.badge', { stored: images.stored, total: images.total }) + : t('sync.short', { ago: formatTimeAgo(sync.at, now, i18n.language) }); return ( -