fix(export): restore loading states for session metrics

This commit is contained in:
aits2026
2026-03-06 12:01:21 +08:00
parent 92d37abbc5
commit 38a0453cbb

View File

@@ -5236,6 +5236,7 @@ function ExportPage() {
const renderContactRow = useCallback((_: number, contact: ContactInfo) => { const renderContactRow = useCallback((_: number, contact: ContactInfo) => {
const matchedSession = sessionRowByUsername.get(contact.username) const matchedSession = sessionRowByUsername.get(contact.username)
const canExport = Boolean(matchedSession?.hasSession) const canExport = Boolean(matchedSession?.hasSession)
const isSessionBindingPending = !matchedSession && (isLoading || isSessionEnriching)
const checked = canExport && selectedSessions.has(contact.username) const checked = canExport && selectedSessions.has(contact.username)
const isRunning = canExport && runningSessionIds.has(contact.username) const isRunning = canExport && runningSessionIds.has(contact.username)
const isQueued = canExport && queuedSessionIds.has(contact.username) const isQueued = canExport && queuedSessionIds.has(contact.username)
@@ -5246,14 +5247,17 @@ function ExportPage() {
const hintedMessages = normalizeMessageCount(matchedSession?.messageCountHint) const hintedMessages = normalizeMessageCount(matchedSession?.messageCountHint)
const displayedMessageCount = countedMessages ?? hintedMessages const displayedMessageCount = countedMessages ?? hintedMessages
const mediaMetric = sessionContentMetrics[contact.username] const mediaMetric = sessionContentMetrics[contact.username]
const messageCountLabel = !canExport const messageCountState: { state: 'value'; text: string } | { state: 'loading' } | { state: 'na'; text: '--' } =
? '--' !canExport
: typeof displayedMessageCount === 'number' ? (isSessionBindingPending ? { state: 'loading' } : { state: 'na', text: '--' })
? displayedMessageCount.toLocaleString('zh-CN') : typeof displayedMessageCount === 'number'
: '获取中' ? { state: 'value', text: displayedMessageCount.toLocaleString('zh-CN') }
: { state: 'loading' }
const metricToDisplay = (value: unknown): { state: 'value'; text: string } | { state: 'loading' } | { state: 'na'; text: '--' } => { const metricToDisplay = (value: unknown): { state: 'value'; text: string } | { state: 'loading' } | { state: 'na'; text: '--' } => {
const normalized = normalizeMessageCount(value) const normalized = normalizeMessageCount(value)
if (!canExport) return { state: 'na', text: '--' } if (!canExport) {
return isSessionBindingPending ? { state: 'loading' } : { state: 'na', text: '--' }
}
if (typeof normalized === 'number') { if (typeof normalized === 'number') {
return { state: 'value', text: normalized.toLocaleString('zh-CN') } return { state: 'value', text: normalized.toLocaleString('zh-CN') }
} }
@@ -5310,8 +5314,10 @@ function ExportPage() {
</div> </div>
<div className="row-message-count"> <div className="row-message-count">
<div className="row-message-stats"> <div className="row-message-stats">
<strong className={`row-message-count-value ${typeof displayedMessageCount === 'number' ? '' : 'muted'}`}> <strong className={`row-message-count-value ${messageCountState.state === 'value' ? '' : 'muted'}`}>
{messageCountLabel} {messageCountState.state === 'loading'
? <Loader2 size={12} className="spin row-media-metric-icon" aria-label="统计加载中" />
: messageCountState.text}
</strong> </strong>
</div> </div>
{canExport && ( {canExport && (
@@ -5424,6 +5430,8 @@ function ExportPage() {
sessionLoadTraceMap, sessionLoadTraceMap,
sessionMessageCounts, sessionMessageCounts,
sessionRowByUsername, sessionRowByUsername,
isLoading,
isSessionEnriching,
showSessionDetailPanel, showSessionDetailPanel,
shouldShowSnsColumn, shouldShowSnsColumn,
snsUserPostCounts, snsUserPostCounts,