Skip to content

Commit 630bd20

Browse files
committed
fix: Initialize animatedOnlineCount when view appears with stats
Problem: - In v1.1.4, online count always shows as 0 - animatedOnlineCount is initialized to 0 as default - When onlineStats changes from nil to a value, animatedOnlineCount stays at 0 - onChange only triggers when the value changes, not on initial load Solution: - Add onAppear to initialize animatedOnlineCount from stats.onlineCount - Check if animatedOnlineCount is 0 and stats has valid count - This ensures the count displays correctly on first load Fixes the regression introduced in PR #57 where animated count feature broke the initial display of online user count.
1 parent 5a207d5 commit 630bd20

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

V2er/View/Widget/Updatable/HeadIndicatorView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ struct HeadIndicatorView: View {
5858
.foregroundColor(.secondaryText)
5959
}
6060
}
61+
.onAppear {
62+
// Initialize animatedOnlineCount when view appears with valid stats
63+
if animatedOnlineCount == 0 && stats.onlineCount > 0 {
64+
animatedOnlineCount = stats.onlineCount
65+
}
66+
}
6167
.onChange(of: stats.onlineCount) { newValue in
6268
withAnimation(.easeInOut(duration: 0.3)) {
6369
animatedOnlineCount = newValue

0 commit comments

Comments
 (0)