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
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/TodoQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct TodoQuery {
struct TodoQuery: Equatable {
enum SortTarget: Equatable, Hashable {
case createdAt
case updatedAt
Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/AccountViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

@Observable
final class AccountViewModel: Store {
struct State {
struct State: Equatable {
var currentProvider: AuthProvider?
var connectedProviders: [AuthProvider] = []
var disconnectedProviders: [AuthProvider] = []
Expand Down Expand Up @@ -87,7 +87,7 @@ final class AccountViewModel: Store {
.filter { !allProviders.contains($0) }
}

self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/LoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import GoogleSignIn

@Observable
final class LoginViewModel: Store {
struct State {
struct State: Equatable {
var signIn: Bool?
var isLoading = false
var showAlert: Bool = false
Expand Down Expand Up @@ -76,7 +76,7 @@ final class LoginViewModel: Store {
state.signIn = result
}

self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/ProfileViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

@Observable
final class ProfileViewModel: Store {
struct State {
struct State: Equatable {
var name: String = ""
var email: String = ""
var statusMessage: String = ""
Expand Down Expand Up @@ -185,7 +185,7 @@ final class ProfileViewModel: Store {
case .updateStatusTextFieldFocus(let focused):
state.showDoneButton = focused
}
self.state = state
if self.state != state { self.state = state }
return effects
}
// swiftlint:enable cyclomatic_complexity
Expand Down
22 changes: 11 additions & 11 deletions DevLog/Presentation/ViewModel/PushNotificationListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

@Observable
final class PushNotificationListViewModel: Store {
struct State {
struct State: Equatable {
var notifications: [PushNotificationItem] = []
var showAlert: Bool = false
var showToast: Bool = false
Expand All @@ -19,7 +19,6 @@ final class PushNotificationListViewModel: Store {
var isLoading: Bool = false
var hasMore: Bool = false
var nextCursor: PushNotificationCursor?
var pendingTask: (PushNotificationItem, Int)?
var query: PushNotificationQuery
var selectedTodoID: TodoIDItem?
}
Expand Down Expand Up @@ -57,6 +56,7 @@ final class PushNotificationListViewModel: Store {
private let toggleReadUseCase: TogglePushNotificationReadUseCase
private let fetchQueryUseCase: FetchPushNotificationQueryUseCase
private let updateQueryUseCase: UpdatePushNotificationQueryUseCase
private var pendingTask: (PushNotificationItem, Int)?

init(
fetchUseCase: FetchPushNotificationsUseCase,
Expand Down Expand Up @@ -99,7 +99,7 @@ final class PushNotificationListViewModel: Store {
effects = reduceByRun(action, state: &state)
}

self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down Expand Up @@ -158,12 +158,12 @@ private extension PushNotificationListViewModel {
switch action {
case .deleteNotification(let item):
var effects: [SideEffect] = []
if let (pendingItem, _) = state.pendingTask {
if let (pendingItem, _) = pendingTask {
effects = [.delete(pendingItem)]
}

if let index = state.notifications.firstIndex(where: { $0.id == item.id }) {
state.pendingTask = (item, index)
pendingTask = (item, index)
state.notifications.remove(at: index)
setToast(&state, isPresented: true)
}
Expand All @@ -175,9 +175,9 @@ private extension PushNotificationListViewModel {
return [.toggleRead(item.todoID)]
}
case .undoDelete:
guard let (item, index) = state.pendingTask else { return [] }
guard let (item, index) = pendingTask else { return [] }
state.notifications.insert(item, at: index)
state.pendingTask = nil
pendingTask = nil
case .setAlert(let isPresented):
setAlert(&state, isPresented: isPresented)
case .toggleSortOption:
Expand Down Expand Up @@ -218,11 +218,11 @@ private extension PushNotificationListViewModel {
state.nextCursor = nil
return [.fetchNotifications(state.query, cursor: nil)]
case .loadNextPage:
guard state.hasMore, !state.isLoading, state.pendingTask == nil else { return [] }
guard state.hasMore, !state.isLoading, pendingTask == nil else { return [] }
return [.fetchNotifications(state.query, cursor: state.nextCursor)]
case .confirmDelete:
guard let (item, _) = state.pendingTask else { return [] }
state.pendingTask = nil
guard let (item, _) = pendingTask else { return [] }
pendingTask = nil
return [.delete(item)]
case .setToast(let isPresented):
setToast(&state, isPresented: isPresented)
Expand All @@ -245,7 +245,7 @@ private extension PushNotificationListViewModel {
state.nextCursor = nil
case .appendNotifications(let notifications, let nextCursor):
let filteredNotifications: [PushNotificationItem]
if let (pendingItem, _) = state.pendingTask {
if let (pendingItem, _) = pendingTask {
filteredNotifications = notifications.filter { $0.id != pendingItem.id }
} else {
filteredNotifications = notifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

@Observable
final class PushNotificationSettingsViewModel: Store {
struct State {
struct State: Equatable {
var pushNotificationEnable: Bool = false
var viewPushNotificationTime: Date = .init()
var sheetPushNotificationTime: Date = .init()
Expand Down Expand Up @@ -99,7 +99,7 @@ final class PushNotificationSettingsViewModel: Store {
state.showTimePicker = false
state.sheetPushNotificationTime = state.viewPushNotificationTime
}
self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/RootViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Combine

@Observable
final class RootViewModel: Store {
struct State {
struct State: Equatable {
var showAlert: Bool = false
var alertTitle: String = ""
var alertMessage: String = ""
Expand Down Expand Up @@ -89,7 +89,7 @@ final class RootViewModel: Store {
state.signIn = result
}

self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/SearchViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import OrderedCollections

@Observable
final class SearchViewModel: Store {
struct State {
struct State: Equatable {
var isLoading: Bool = false
var isSearching: Bool = false
var searchQuery: String = ""
Expand Down Expand Up @@ -124,7 +124,7 @@ final class SearchViewModel: Store {
state.showAllWebPages = shouldShowAll
}

self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/SettingViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Combine

@Observable
final class SettingViewModel: Store {
struct State {
struct State: Equatable {
var theme: SystemTheme = .automatic
var dirSize: Int64 = 0
var isLoading = false
Expand Down Expand Up @@ -95,7 +95,7 @@ final class SettingViewModel: Store {
}
}

self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/TodoDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

@Observable
final class TodoDetailViewModel: Store {
struct State {
struct State: Equatable {
var todo: Todo?
var isLoading: Bool = false
var showAlert: Bool = false
Expand Down Expand Up @@ -70,7 +70,7 @@ final class TodoDetailViewModel: Store {
effects = [.upsertTodo(todo)]
}

self.state = state
if self.state != state { self.state = state }
return effects
}

Expand Down
6 changes: 3 additions & 3 deletions DevLog/Presentation/ViewModel/TodoEditorViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import OrderedCollections

@Observable
final class TodoEditorViewModel: Store {
struct State {
struct State: Equatable {
var title: String = ""
var content: String = ""
var dueDate: Date?
var tags: OrderedSet<String> = []
var tagText: String = ""
var focusOnEditor: Bool = false
var hasDueDate: Bool { return dueDate != nil }
var hasDueDate: Bool { dueDate != nil }
var tabViewTag: Tag = .editor
var isValidToSave: Bool {
!title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty &&
Expand Down Expand Up @@ -111,7 +111,7 @@ final class TodoEditorViewModel: Store {
}
}

self.state = state
if self.state != state { self.state = state }
return []
}
}
Expand Down
Loading