File tree Expand file tree Collapse file tree
DevLog/Presentation/ViewModel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -157,13 +157,17 @@ final class PushNotificationListViewModel: Store {
157157 }
158158 case . undoDelete( let notificationId) :
159159 Task {
160+ // defer을 통해 setLoading을 false로 제어하지 않는 이유
161+ // send(.fetchNotifications)를 통해 false로 처리될 것이기 때문
162+ send ( . setLoading( true ) )
163+
160164 do {
161165 try await undoDeleteUseCase. execute ( notificationId)
162- send ( . fetchNotifications)
163166 } catch {
164167 send ( . setAlert( isPresented: true ) )
165- send ( . fetchNotifications)
166168 }
169+
170+ send ( . fetchNotifications)
167171 }
168172 case . toggleRead( let notificationId) :
169173 Task {
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ final class TodoListViewModel: Store {
137137 return effects
138138 }
139139
140+ // swiftlint:disable function_body_length
140141 func run( _ effect: SideEffect ) {
141142 switch effect {
142143 case . fetch:
@@ -230,15 +231,21 @@ final class TodoListViewModel: Store {
230231 }
231232 case . undoDelete( let todoId) :
232233 Task {
234+ // defer을 통해 setLoading을 false로 제어하지 않는 이유
235+ // send(.refresh)를 통해 false로 처리될 것이기 때문
236+ send ( . setLoading( true ) )
237+
233238 do {
234239 try await undoDeleteTodoUseCase. execute ( todoId)
235- send ( . refresh)
236240 } catch {
237- send ( . setAlert( true ) ) ; send ( . refresh )
241+ send ( . setAlert( true ) )
238242 }
243+
244+ send ( . refresh)
239245 }
240246 }
241247 }
248+ // swiftlint:enable function_body_length
242249}
243250
244251// MARK: - Reduce Methods
You can’t perform that action at this time.
0 commit comments