File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Features/Feed/Sources/Feed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ public struct FeedView<NavigationStore: NavigationStoreProtocol>: View {
9292 searchText = newValue
9393 }
9494 }
95+ . onChange ( of: selectedPostType) { _ in
96+ // Clear selection when category changes to prevent stale sidebar selection
97+ selectedPostId = nil
98+ }
9599 . task { @Sendable in
96100 // Set the navigation store for the voting view model
97101 votingViewModel. navigationStore = navigationStore
@@ -121,7 +125,7 @@ public struct FeedView<NavigationStore: NavigationStoreProtocol>: View {
121125 Group {
122126 if viewModel. hasActiveSearch {
123127 searchContentView
124- } else if viewModel. isLoading, viewModel. posts. isEmpty {
128+ } else if viewModel. isLoading && viewModel. posts. isEmpty && viewModel . postType != . bookmarks {
125129 AppLoadingStateView ( message: " Loading... " )
126130 } else if shouldShowBookmarksEmptyState {
127131 AppEmptyStateView (
@@ -172,6 +176,7 @@ public struct FeedView<NavigationStore: NavigationStoreProtocol>: View {
172176 . if ( isSidebar) { view in view. listStyle ( . sidebar) }
173177 . if ( !isSidebar) { view in view. listStyle ( . plain) }
174178 . frame ( maxWidth: . infinity, maxHeight: . infinity)
179+ . id ( selectedPostType)
175180 }
176181
177182 @ViewBuilder
Original file line number Diff line number Diff line change @@ -213,11 +213,15 @@ public final class FeedViewModel: @unchecked Sendable {
213213
214214 postType = newType
215215 persistLastFeedCategoryIfNeeded ( )
216- await refreshFeed ( )
216+ reset ( clearPosts: true ) // Clear posts immediately to prevent flash of old data
217+ await feedLoader. refresh ( )
217218 }
218219
219220 @MainActor
220- private func reset( ) {
221+ private func reset( clearPosts: Bool = false ) {
222+ if clearPosts {
223+ feedLoader. data = [ ]
224+ }
221225 postIds = Set ( )
222226 pageIndex = 1
223227 lastPostId = 0
You can’t perform that action at this time.
0 commit comments