diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift index 63b7a37..89788f2 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(EventKit) - import EventKit +@preconcurrency import EventKit #endif import Factory import OversizeCalendarService @@ -14,13 +14,13 @@ import OversizeModels import SwiftUI #if !os(tvOS) - public enum CreateEventType: Equatable { +public enum CreateEventType: Equatable, @unchecked Sendable { case new(Date?, calendar: EKCalendar?) case update(EKEvent) } - @MainActor - public class CreateEventViewModel: ObservableObject { + +public class CreateEventViewModel: ObservableObject, @unchecked Sendable { @Injected(\.calendarService) private var calendarService: CalendarService @Injected(\.locationService) private var locationService: LocationServiceProtocol diff --git a/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift b/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift index 0dfa02b..b529465 100644 --- a/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift +++ b/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(Contacts) && canImport(EventKit) - import Contacts +@preconcurrency import Contacts import EventKit #endif import Factory @@ -29,9 +29,9 @@ import SwiftUI func fetchData() async { state = .loading let _ = await contactsService.requestAccess() - do { + let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] - let result = try await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) + let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) switch result { case let .success(data): log("✅ CNContact fetched") @@ -40,9 +40,7 @@ import SwiftUI log("❌ CNContact not fetched (\(error.title))") state = .error(error) } - } catch { - state = .error(.custom(title: "Not contacts")) - } + } func getContactFromEmail(email: String, contacts: [CNContact]) -> CNContact? { diff --git a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift index 8e7f414..c9ad11f 100644 --- a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(Contacts) - import Contacts +@preconcurrency import Contacts #endif import Factory import OversizeContactsService @@ -24,9 +24,9 @@ import SwiftUI func fetchData() async { state = .loading let _ = await contactsService.requestAccess() - do { + let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] - let result = try await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) + let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) switch result { case let .success(data): log("✅ CNContact fetched") @@ -35,9 +35,7 @@ import SwiftUI log("❌ CNContact not fetched (\(error.title))") state = .error(error) } - } catch { - state = .error(.custom(title: "Not contacts")) - } + } func getContactFromEmail(email: String, contacts: [CNContact]) -> CNContact? { diff --git a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift index 2c47623..b43a1d3 100644 --- a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(Contacts) - import Contacts +@preconcurrency import Contacts #endif import Factory import OversizeContactsService @@ -26,9 +26,9 @@ import SwiftUI let status = await contactsService.requestAccess() switch status { case .success: - do { + let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] - let result = try await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) + let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) switch result { case let .success(data): log("✅ CNContact fetched") @@ -37,9 +37,7 @@ import SwiftUI log("❌ CNContact not fetched (\(error.title))") state = .error(error) } - } catch { - state = .error(.contacts(type: .unknown)) - } + case let .failure(error): state = .error(error) } diff --git a/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift b/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift index 0519299..cd32569 100644 --- a/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift +++ b/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift @@ -13,7 +13,7 @@ import SwiftUI #if !os(watchOS) @MainActor - class AddressPickerViewModel: NSObject, ObservableObject { +class AddressPickerViewModel: NSObject, ObservableObject { @Injected(\.locationService) var locationService: LocationServiceProtocol @Published var locationResults: [MKLocalSearchCompletion] = .init() @@ -60,7 +60,7 @@ import SwiftUI } } - extension AddressPickerViewModel: MKLocalSearchCompleterDelegate { +extension AddressPickerViewModel: @preconcurrency MKLocalSearchCompleterDelegate { func completerDidUpdateResults(_ completer: MKLocalSearchCompleter) { currentPromise?(.success(completer.results)) } diff --git a/Sources/OversizeNotificationKit/Model/LocalNotificationAlertsTimes.swift b/Sources/OversizeNotificationKit/Model/LocalNotificationAlertsTimes.swift index 227a8e9..3ace115 100644 --- a/Sources/OversizeNotificationKit/Model/LocalNotificationAlertsTimes.swift +++ b/Sources/OversizeNotificationKit/Model/LocalNotificationAlertsTimes.swift @@ -5,7 +5,7 @@ import Foundation -public enum LocalNotificationTime: CaseIterable, Equatable, Identifiable { +public enum LocalNotificationTime: CaseIterable, Equatable, Identifiable, @unchecked Sendable { case oneMinuteBefore, fiveMinutesBefore, tenMinutesBefore, thirtyMinutesBefore, oneHourBefore, twoHoursBefore, oneDayBefore, twoDaysBefore, oneWeekBefore public var title: String { @@ -58,5 +58,5 @@ public enum LocalNotificationTime: CaseIterable, Equatable, Identifiable { title } - public static var allCases: [LocalNotificationTime] = [.oneMinuteBefore, .fiveMinutesBefore, .tenMinutesBefore, .thirtyMinutesBefore, .oneHourBefore, .twoHoursBefore, .oneDayBefore, .twoDaysBefore, .oneWeekBefore] + public static let allCases: [LocalNotificationTime] = [.oneMinuteBefore, .fiveMinutesBefore, .tenMinutesBefore, .thirtyMinutesBefore, .oneHourBefore, .twoHoursBefore, .oneDayBefore, .twoDaysBefore, .oneWeekBefore] }