Skip to content

Commit b6cd2f6

Browse files
committed
fix: Today 데이터 fetch 시점을 탭 선택 상태 기준으로 변경
1 parent 9d33d26 commit b6cd2f6

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

Application/DevLogPresentation/Sources/Main/MainView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct MainView: View {
4444
.onChange(of: selectedTab) { _, newValue in
4545
if newValue == .home {
4646
homeViewCoordinator.loadInitialData()
47+
} else if newValue == .today {
48+
todayViewCoordinator.fetchData()
4749
}
4850
}
4951
.alert(

Application/DevLogPresentation/Sources/Today/TodayView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct TodayView: View {
2929
.toolbar { toolbarContent }
3030
.background(NavigationBarConfigurator())
3131
.refreshable { coordinator.viewModel.send(.refresh) }
32-
.onAppear { coordinator.viewModel.send(.onAppear) }
3332
.alert(
3433
coordinator.viewModel.state.alertTitle,
3534
isPresented: Binding(

Application/DevLogPresentation/Sources/Today/TodayViewCoordinator.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ final class TodayViewCoordinator {
2424
updateTodayDisplayOptionsUseCase: container.resolve(UpdateTodayDisplayOptionsUseCase.self)
2525
)
2626
}
27+
28+
func fetchData() {
29+
viewModel.send(.fetchData)
30+
}
2731
}

Application/DevLogPresentation/Sources/Today/TodayViewModel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ final class TodayViewModel: Store {
6262
case resetDisplayOptions
6363
case completeTodo(TodayTodoItem)
6464
case togglePinned(TodayTodoItem)
65-
case onAppear
65+
case fetchData
6666
case fetchTodos([TodayTodoItem])
6767
case setLoading(Bool)
6868
case updateTodo(TodayTodoItem)
@@ -178,7 +178,7 @@ final class TodayViewModel: Store {
178178
case .refresh, .setAlert, .setSectionScope, .setDueDateVisibility, .setFocusVisibility,
179179
.resetDisplayOptions, .completeTodo, .togglePinned:
180180
effects = reduceByUser(action, state: &state)
181-
case .onAppear:
181+
case .fetchData:
182182
effects = reduceByView(action, state: &state)
183183
case .fetchTodos, .setLoading, .updateTodo, .removeTodo:
184184
effects = reduceByRun(action, state: &state)
@@ -305,7 +305,7 @@ private extension TodayViewModel {
305305

306306
func reduceByView(_ action: Action, state: inout State) -> [SideEffect] {
307307
switch action {
308-
case .onAppear:
308+
case .fetchData:
309309
return [.fetchTodos]
310310
default:
311311
break

0 commit comments

Comments
 (0)