feat: enhance models and services with Sendable conformance, add preview data for debugging

This commit is contained in:
2026-03-14 07:18:35 +07:00
parent a4b475b13f
commit 758f5ec05f
17 changed files with 851 additions and 198 deletions
+18
View File
@@ -11,6 +11,12 @@ class SettingsViewModel: ObservableObject {
private let service = NotificationsAPIService.shared
func loadSessions() async {
#if DEBUG
if PreviewData.isPreviewMode {
sessions = PreviewData.mockSessions
return
}
#endif
isLoading = true
defer { isLoading = false }
do {
@@ -21,6 +27,12 @@ class SettingsViewModel: ObservableObject {
}
func deleteSession(_ session: SessionResponse) async {
#if DEBUG
if PreviewData.isPreviewMode {
sessions.removeAll { $0.id == session.id }
return
}
#endif
do {
try await service.deleteSession(id: session.id)
sessions.removeAll { $0.id == session.id }
@@ -30,6 +42,12 @@ class SettingsViewModel: ObservableObject {
}
func changePassword(current: String, new: String) async -> Bool {
#if DEBUG
if PreviewData.isPreviewMode {
successMessage = "Пароль успешно изменён"
return true
}
#endif
isLoading = true
error = nil
defer { isLoading = false }