Skip to content
Merged
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
14 changes: 10 additions & 4 deletions DevLog/Presentation/ViewModel/PushNotificationListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,17 @@ private extension PushNotificationListViewModel {
func reduceByUser(_ action: Action, state: inout State) -> [SideEffect] {
switch action {
case .deleteNotification(let item):
if let index = state.notifications.firstIndex(where: { $0.id == item.id }) {
state.pendingTask = (item, index)
state.notifications.remove(at: index)
setToast(&state, isPresented: true, for: .delete)
var effects: [SideEffect] = []
if let (pendingItem, _) = state.pendingTask {
effects.append(.delete(pendingItem))
}
guard let index = state.notifications.firstIndex(where: { $0.id == item.id }) else {
return []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

guard let 구문이 실패하여 else 블록이 실행될 때, 이전에 effects 배열에 추가되었을 수 있는 SideEffect가 무시되고 빈 배열이 반환됩니다. 이로 인해 이전에 대기 중이던 삭제 작업이 실행되지 않는 버그가 발생할 수 있습니다. return [] 대신 return effects를 사용하여, 이전에 추가된 SideEffect가 정상적으로 실행되도록 해야 합니다.

Suggested change
return []
return effects

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 리뷰를 시작하려면 /gemini review 명령어를 사용해 주세요. 이 스레드에서는 추가적인 답변이 필요하지 않습니다.

}
state.pendingTask = (item, index)
state.notifications.remove(at: index)
setToast(&state, isPresented: true, for: .delete)
return effects
case .toggleRead(let item):
if let index = state.notifications.firstIndex(where: { $0.id == item.id }) {
state.notifications[index].isRead.toggle()
Expand Down