-
Notifications
You must be signed in to change notification settings - Fork 107
Show loading state when switching category #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show loading state when switching category #324
Conversation
- Show loading indicator when switching categories (except Bookmarks) - Automatically scroll to top of feed on category change - Add isChangingCategory flag to track category switching state
Use existing isLoading and postType instead of separate isChangingCategory flag
|
Caution Review failedThe pull request is closed. WalkthroughReset Changes
Sequence Diagram(s)sequenceDiagram
participant UI as FeedView
participant VM as FeedViewModel
participant List as feedListView
UI->>VM: User selects new selectedPostType
VM-->>UI: selectedPostType updated
Note over UI: onChange clears selectedPostId
UI->>UI: selectedPostId = nil
UI->>List: feedListView re-evaluated (.id(selectedPostType))
Note right of VM: changePostType -> reset(clearPosts: true) -> feedLoader.refresh()
alt isLoading && posts.isEmpty && selectedPostType != bookmarks
UI->>UI: render AppLoadingStateView
else
UI->>UI: render feedListView content
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Use id() modifier to recreate list at top without animation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Features/Feed/Sources/Feed/FeedView.swift(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
Features/*/Sources/**/*.swift
📄 CodeRabbit inference engine (AGENTS.md)
Features/*/Sources/**/*.swift: SwiftUI views in Features should use @EnvironmentObject for navigation
Annotate UI code with @mainactor
Files:
Features/Feed/Sources/Feed/FeedView.swift
Features/*/Sources/**/*View.swift
📄 CodeRabbit inference engine (AGENTS.md)
Use @StateObject for view-owned ViewModels in SwiftUI Views
Files:
Features/Feed/Sources/Feed/FeedView.swift
**/*.swift
📄 CodeRabbit inference engine (AGENTS.md)
**/*.swift: Use Swift concurrency (async/await) instead of completion handlers where appropriate
Adopt Sendable where needed to ensure thread safety across concurrency boundaries
Files:
Features/Feed/Sources/Feed/FeedView.swift
🧠 Learnings (2)
📚 Learning: 2025-09-14T17:42:10.615Z
Learnt from: CR
Repo: weiran/Hackers PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-14T17:42:10.615Z
Learning: Applies to Features/*/Sources/**/*View.swift : Use StateObject for view-owned ViewModels in SwiftUI Views
Applied to files:
Features/Feed/Sources/Feed/FeedView.swift
📚 Learning: 2025-09-14T17:42:10.615Z
Learnt from: CR
Repo: weiran/Hackers PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-14T17:42:10.615Z
Learning: Applies to Features/*/Sources/**/*ViewModel.swift : Feature ViewModels must be ObservableObject and expose state via Published properties
Applied to files:
Features/Feed/Sources/Feed/FeedView.swift
🧬 Code graph analysis (1)
Features/Feed/Sources/Feed/FeedView.swift (2)
Features/Feed/Sources/Feed/FeedViewModel.swift (4)
isLoadingMore(13-154)replacePost(148-153)changePostType(129-135)reset(137-144)Features/Feed/Tests/FeedTests/FeedViewTests.swift (1)
selectedPost(17-51)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (1)
Features/Feed/Sources/Feed/FeedView.swift (1)
124-124: LGTM: Bookmarks correctly excluded from loading indicator.The condition properly excludes bookmarks from displaying the loading state, which is consistent with the bookmark-specific empty state handling. When bookmarks are loading and empty, the view falls through to display the feed list (which will be empty), avoiding a potentially confusing loading indicator for what is likely an instant local operation.
Reset selectedPostId to prevent stale selection state when list is recreated
Show loading when selectedPostType differs from viewModel.postType to prevent flash of old data during category transition
Call reset() synchronously after postType change before any await to ensure posts are cleared before view re-renders, eliminating flash of old data
…zTbEhavoXDwAGfgv1
Summary by CodeRabbit