Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// PushNotificationViewModel.swift
// PushNotificationListViewModel.swift
// DevLog
//
// Created by 최윤진 on 11/22/25.
//

import Foundation

final class PushNotificationViewModel: Store {
final class PushNotificationListViewModel: Store {
struct State {
var notifications: [PushNotification] = []
var showAlert: Bool = false
Expand Down Expand Up @@ -157,7 +157,7 @@ final class PushNotificationViewModel: Store {
}

// MARK: - Reduce Methods
private extension PushNotificationViewModel {
private extension PushNotificationListViewModel {
func reduceByUser(_ action: Action, state: inout State) -> [SideEffect] {
switch action {
case .deleteNotification(let item):
Expand Down Expand Up @@ -197,8 +197,12 @@ private extension PushNotificationViewModel {
updateQueryUseCase.execute(state.query)
state.nextCursor = nil
return [.fetchNotifications(state.query, cursor: nil)]
case .tapNotification(let notification):
state.selectedTodoID = TodoIDItem(id: notification.todoID)
case .tapNotification(let item):
state.selectedTodoID = TodoIDItem(id: item.todoID)
if let index = state.notifications.firstIndex(where: { $0.id == item.id }), !item.isRead {
state.notifications[index].isRead.toggle()
return [.toggleRead(item.todoID)]
}
default:
break
}
Expand Down Expand Up @@ -252,7 +256,7 @@ private extension PushNotificationViewModel {
}
}

private extension PushNotificationViewModel {
private extension PushNotificationListViewModel {
func setAlert(
_ state: inout State,
isPresented: Bool,
Expand Down
2 changes: 1 addition & 1 deletion DevLog/UI/Common/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct MainView: View {
Image(systemName: "house.fill")
Text("홈")
}
PushNotificationView(viewModel: PushNotificationViewModel(
PushNotificationListView(viewModel: PushNotificationListViewModel(
fetchUseCase: container.resolve(FetchPushNotificationsUseCase.self),
deleteUseCase: container.resolve(DeletePushNotificationUseCase.self),
toggleReadUseCase: container.resolve(TogglePushNotificationReadUseCase.self),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//
// PushNotificationView.swift
// PushNotificationListView.swift
// DevLog
//
// Created by opfic on 5/14/25.
//

import SwiftUI

struct PushNotificationView: View {
struct PushNotificationListView: View {
@StateObject private var router = NavigationRouter()
@StateObject var viewModel: PushNotificationViewModel
@StateObject var viewModel: PushNotificationListViewModel
@Environment(\.sceneWidth) private var sceneWidth
@Environment(\.colorScheme) private var colorScheme
@Environment(\.diContainer) private var container: DIContainer
Expand Down