Skip to content

Commit e96cf49

Browse files
committed
fix: Profile 데이터 fetch 시점을 탭 선택 상태 기준으로 변경
1 parent 16d608d commit e96cf49

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

Application/DevLogPresentation/Sources/Main/MainView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct MainView: View {
4646
homeViewCoordinator.fetchData()
4747
} else if newValue == .today {
4848
todayViewCoordinator.fetchData()
49+
} else if newValue == .profile {
50+
profileViewCoordinator.fetchData()
4951
}
5052
}
5153
.alert(

Application/DevLogPresentation/Sources/Profile/ProfileView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ struct ProfileView: View {
118118
AccountView(viewModel: coordinator.makeAccountViewModel())
119119
}
120120
}
121-
.onAppear { coordinator.viewModel.send(.onAppear) }
122121
.onChange(of: focused) { _, newValue in
123122
withAnimation {
124123
coordinator.viewModel.send(.updateStatusTextFieldFocus(newValue))

Application/DevLogPresentation/Sources/Profile/ProfileViewCoordinator.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ final class ProfileViewCoordinator {
3838
)
3939
}
4040

41+
func fetchData() {
42+
viewModel.send(.fetchData)
43+
}
44+
4145
func makeAccountViewModel() -> AccountViewModel {
4246
AccountViewModel(
4347
fetchProvidersUseCase: container.resolve(FetchAuthProvidersUseCase.self),

Application/DevLogPresentation/Sources/Profile/ProfileViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class ProfileViewModel: Store {
3434
}
3535

3636
enum Action {
37-
case onAppear, refresh
37+
case fetchData, refresh
3838
case networkStatusChanged(Bool)
3939
case setLoading(Bool)
4040
case setAlert(Bool)
@@ -98,7 +98,7 @@ final class ProfileViewModel: Store {
9898
var state = self.state
9999
var effects: [SideEffect] = []
100100
switch action {
101-
case .onAppear, .refresh:
101+
case .fetchData, .refresh:
102102
if state.selectedQuarterStart == nil {
103103
guard let quarterStart = quarterStart(for: Date()) else { break }
104104
state.selectedQuarterStart = quarterStart

0 commit comments

Comments
 (0)