{t('sight.needMember')}
} + {loading ?{entry('identity.loginAgain')}
+ : denied ?{t('sight.needMember')}
+ :{entry('identity.unreachable')}{' '} +
}{t('sight.needMember')}
} + {loading ?{entry('identity.loginAgain')}
+ : denied ?{t('sight.needMember')}
+ :{entry('identity.unreachable')}{' '} +
}{t('sight.publishedResultsError')}
} - {published === undefined ?{t('sight.publishedError')}
- :{t('sight.publishedError')}{' '} +
} + {published.data && (board.error || !board.data && !boardPending) &&{t('sight.publishedResultsError')}{' '} +
} + {listPending &&{t('sight.storageError')}
: Boolean(legacyQuestions?.length) &&{t('sight.noPublished')}
; } -function QuestionCard({ question, top, count, choirId, ready, open }: { +function QuestionCard({ question, top, count, reads, ready, open }: { question: PublishedQuestion; top?: SightSingingLeaderboard['results']; count?: number; ready: boolean; open: () => void; - choirId: string; + reads: ChallengeReads; }) { const t = useMessages('practice'); - const formatScore = useSightSingingScoreFormat(); const rankingId = useId(); const [expanded, setExpanded] = useState(false); - const [retry, setRetry] = useState(0); - const [details, setDetails] = useState<{ retry: number; rows: PublishedSightSingingResult[] | null }>(); - useEffect(() => { - if (!expanded) return; - const controller = new AbortController(); - void readSightSingingResults(choirId, question.id, {}, controller.signal).then(payload => { - if (!controller.signal.aborted) setDetails({ retry, rows: payload.results }); - }).catch(() => { - if (!controller.signal.aborted) setDetails({ retry, rows: null }); - }); - return () => controller.abort(); - }, [expanded, choirId, question.id, retry]); - const loaded = details?.retry === retry ? details.rows : undefined; - const rows = expanded ? loaded : top; const showDetailsButton = expanded || Boolean(top?.length); const showVersions = question.version > 1; return{t('sight.publishedResultsError')}{' '} -
- :{expanded || ready ? t('sight.noCardScores') : '—'}
} + {expanded ?{t('sight.publishedResultsError')}{' '} + +
; +} + +function QuestionRanks({ rows, ready, expanded, showVersions }: { + rows?: SightSingingLeaderboard['results']; ready: boolean; expanded?: boolean; showVersions?: boolean; +}) { + const t = useMessages('practice'); + const formatScore = useSightSingingScoreFormat(); + return rows?.length ?{ready ? t('sight.noCardScores') : '—'}
; +} + function PracticePanel({ title, icon, compact, children }: { title: string; icon: ReactNode; compact?: boolean; children: ReactNode; }) { @@ -292,40 +358,34 @@ function PublishedResultRow({ row, place, tied, showVersions, onRemove }: { ; } -function PublishedResults({ choirId, questionId, version, generation, userId }: { - choirId: string; questionId: string; version: number; generation: number; userId: string; +function PublishedResults({ reads, questionId, version, generation, userId }: { + reads: ChallengeReads; questionId: string; version: number; generation: number; userId: string; }) { + const { choirId, canReadCloud } = reads; const t = useMessages('practice'); const showVersions = version > 1; const speedFilterId = useId(); const [filters, setFilters] = useState{t('sight.withdrawFailed')}
} - {rows === undefined ?{t('sight.publishedResultsError')}
+ {!rows && canReadCloud && !results.error ?{t('sight.publishedResultsError')}
: rows.length === 0 ?{t('sight.publishedResultsEmpty')}
:{t('sight.sourceError')}
} + {(status === 'error' || status === 'unavailable') &&{t('sight.sourceError')}
} {needsSource &&{t('sight.sourceChanged')}
} - {loaded.failed && source?.kind !== 'upload' &&{t('sight.sourceError')}
} + {loaded.failed && source?.kind !== 'upload' &&{t('sight.sourceError')}
} {typeof issue === 'string' &&{t(`sight.${issue}`)}
} {failed &&{t('sight.publishError')}
} {!editing && loaded.document && selected &&