feat: 增加首次加载标志以优化数据请求逻辑

- 在FeedListFeature中新增isLoaded属性,确保仅在首次加载时请求feed数据,提升性能和用户体验。
This commit is contained in:
edwinQQQ
2025-07-22 17:26:29 +08:00
parent c8ff40cac1
commit 60b3f824be

View File

@@ -11,6 +11,8 @@ struct FeedListFeature {
var isEditFeedPresented: Bool = false // EditFeedView
//
var moments: [MomentsInfo] = []
//
var isLoaded: Bool = false
}
enum Action: Equatable {
@@ -28,7 +30,9 @@ struct FeedListFeature {
func reduce(into state: inout State, action: Action) -> Effect<Action> {
switch action {
case .onAppear:
// feed
// feed
guard !state.isLoaded else { return .none }
state.isLoaded = true
return .send(.fetchFeeds)
case .fetchFeeds:
state.isLoading = true