Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Application/DevLogPresentation/Sources/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct MainView: View {
.onChange(of: selectedTab) { _, newValue in
if newValue == .home {
homeViewCoordinator.loadInitialData()
} else if newValue == .today {
todayViewCoordinator.fetchData()
}
}
Comment thread
opficdev marked this conversation as resolved.
Outdated
.alert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct TodayView: View {
.toolbar { toolbarContent }
.background(NavigationBarConfigurator())
.refreshable { coordinator.viewModel.send(.refresh) }
.onAppear { coordinator.viewModel.send(.onAppear) }
.alert(
coordinator.viewModel.state.alertTitle,
isPresented: Binding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ final class TodayViewCoordinator {
updateTodayDisplayOptionsUseCase: container.resolve(UpdateTodayDisplayOptionsUseCase.self)
)
}

func fetchData() {
viewModel.send(.fetchData)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class TodayViewModel: Store {
case resetDisplayOptions
case completeTodo(TodayTodoItem)
case togglePinned(TodayTodoItem)
case onAppear
case fetchData
case fetchTodos([TodayTodoItem])
case setLoading(Bool)
case updateTodo(TodayTodoItem)
Expand Down Expand Up @@ -178,7 +178,7 @@ final class TodayViewModel: Store {
case .refresh, .setAlert, .setSectionScope, .setDueDateVisibility, .setFocusVisibility,
.resetDisplayOptions, .completeTodo, .togglePinned:
effects = reduceByUser(action, state: &state)
case .onAppear:
case .fetchData:
effects = reduceByView(action, state: &state)
case .fetchTodos, .setLoading, .updateTodo, .removeTodo:
effects = reduceByRun(action, state: &state)
Expand Down Expand Up @@ -305,7 +305,7 @@ private extension TodayViewModel {

func reduceByView(_ action: Action, state: inout State) -> [SideEffect] {
switch action {
case .onAppear:
case .fetchData:
return [.fetchTodos]
default:
break
Expand Down
Loading