fix(sns): derive per-user totals from timeline counts map

This commit is contained in:
aits2026
2026-03-05 17:44:24 +08:00
parent 38af8de469
commit 3388b7a122
5 changed files with 80 additions and 50 deletions

View File

@@ -497,11 +497,12 @@ export default function SnsPage() {
setAuthorTimelineTotalPosts(null)
try {
const result = await window.electronAPI.sns.getUserPostStats(target.username)
const result = await window.electronAPI.sns.getUserPostCounts()
if (requestToken !== authorTimelineStatsTokenRef.current) return
if (result.success && result.data) {
setAuthorTimelineTotalPosts(Math.max(0, Number(result.data.totalPosts || 0)))
if (result.success && result.counts) {
const totalPosts = result.counts[target.username] ?? 0
setAuthorTimelineTotalPosts(Math.max(0, Number(totalPosts || 0)))
} else {
setAuthorTimelineTotalPosts(null)
}

View File

@@ -789,6 +789,7 @@ export interface ElectronAPI {
onExportProgress: (callback: (payload: { current: number; total: number; status: string }) => void) => () => void
selectExportDir: () => Promise<{ canceled: boolean; filePath?: string }>
getSnsUsernames: () => Promise<{ success: boolean; usernames?: string[]; error?: string }>
getUserPostCounts: () => Promise<{ success: boolean; counts?: Record<string, number>; error?: string }>
getExportStatsFast: () => Promise<{ success: boolean; data?: { totalPosts: number; totalFriends: number; myPosts: number | null }; error?: string }>
getExportStats: () => Promise<{ success: boolean; data?: { totalPosts: number; totalFriends: number; myPosts: number | null }; error?: string }>
getUserPostStats: (username: string) => Promise<{ success: boolean; data?: { username: string; totalPosts: number }; error?: string }>