Skip to content

Commit 55cf03f

Browse files
graycreateclaude
andcommitted
fix: address additional Copilot PR review comments
- Fixed rotation angle logic in TopBar to use conditional assignment instead of continuous increment - Extracted duplicate login check logic in FilterMenuView into local variable - Reduced code duplication in FeedReducer by extracting supportsLoadMore() calls into variables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0e574b3 commit 55cf03f

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

V2er/State/DataFlow/Reducers/FeedReducer.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ func feedStateReducer(_ state: FeedState, _ action: Action) -> (FeedState, Actio
2323
if case let .success(newsInfo) = action.result {
2424
state.feedInfo = newsInfo ?? FeedInfo()
2525
state.willLoadPage = 1
26-
state.hasMoreData = state.selectedTab.supportsLoadMore()
26+
let supportsLoadMore = state.selectedTab.supportsLoadMore()
27+
state.hasMoreData = supportsLoadMore
2728
} else { }
2829
case let action as FeedActions.LoadMore.Start:
2930
guard !state.refreshing else { break }
@@ -33,7 +34,8 @@ func feedStateReducer(_ state: FeedState, _ action: Action) -> (FeedState, Actio
3334
break
3435
case let action as FeedActions.LoadMore.Done:
3536
state.loadingMore = false
36-
state.hasMoreData = state.selectedTab.supportsLoadMore()
37+
let supportsLoadMore = state.selectedTab.supportsLoadMore()
38+
state.hasMoreData = supportsLoadMore
3739
if case let .success(newsInfo) = action.result {
3840
state.willLoadPage += 1
3941
state.feedInfo.append(feedInfo: newsInfo!)
@@ -46,7 +48,8 @@ func feedStateReducer(_ state: FeedState, _ action: Action) -> (FeedState, Actio
4648
state.selectedTab = action.tab
4749
Tab.saveSelectedTab(action.tab)
4850
state.showFilterMenu = false
49-
state.hasMoreData = action.tab.supportsLoadMore()
51+
let supportsLoadMore = action.tab.supportsLoadMore()
52+
state.hasMoreData = supportsLoadMore
5053
followingAction = FeedActions.FetchData.Start()
5154
case let action as FeedActions.ToggleFilterMenu:
5255
state.showFilterMenu.toggle()

V2er/View/Feed/FilterMenuView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ struct FilterMenuView: View {
3535
ScrollView {
3636
VStack(spacing: 4) {
3737
ForEach(Tab.allTabs, id: \.self) { tab in
38+
let tabNeedsLogin = tab.needsLogin() && !AccountState.hasSignIn()
3839
TabFilterMenuItem(
3940
tab: tab,
4041
isSelected: tab == selectedTab,
41-
needsLogin: tab.needsLogin() && !AccountState.hasSignIn()
42+
needsLogin: tabNeedsLogin
4243
) {
4344
// Soft haptic feedback
4445
let impactFeedback = UIImpactFeedbackGenerator(style: .light)
4546
impactFeedback.impactOccurred()
4647

47-
if tab.needsLogin() && !AccountState.hasSignIn() {
48+
if tabNeedsLogin {
4849
Toast.show("登录后才能查看「\(tab.displayName())」下的内容")
4950
} else {
5051
onTabSelected(tab)

V2er/View/Widget/TopBar.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// TopBar.swift
33
// V2er
44
//
5-
// Created by Seth on 2021/6/24.
5+
// Created by Gray on 2021/6/24.
66
// Copyright © 2021 lessmore.io. All rights reserved.
77
//
88

@@ -70,7 +70,7 @@ struct TopBar: View {
7070
.forceClickable()
7171
.onChange(of: store.appState.feedState.showFilterMenu) { newValue in
7272
withAnimation {
73-
rotationAngle += 180
73+
rotationAngle = newValue ? 180 : 0
7474
}
7575
}
7676
.onTapGesture {

0 commit comments

Comments
 (0)