diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift index 89788f2..004698e 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(EventKit) -@preconcurrency import EventKit + @preconcurrency import EventKit #endif import Factory import OversizeCalendarService @@ -14,13 +14,12 @@ import OversizeModels import SwiftUI #if !os(tvOS) -public enum CreateEventType: Equatable, @unchecked Sendable { + public enum CreateEventType: Equatable, @unchecked Sendable { case new(Date?, calendar: EKCalendar?) case update(EKEvent) } - -public class CreateEventViewModel: ObservableObject, @unchecked Sendable { + 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 b529465..d597c36 100644 --- a/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift +++ b/Sources/OversizeContactsKit/AttendeesList/AttendeesViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(Contacts) && canImport(EventKit) -@preconcurrency import Contacts + @preconcurrency import Contacts import EventKit #endif import Factory @@ -29,18 +29,17 @@ import SwiftUI func fetchData() async { state = .loading let _ = await contactsService.requestAccess() - - let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] - let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) - switch result { - case let .success(data): - log("✅ CNContact fetched") - state = .result(data) - case let .failure(error): - log("❌ CNContact not fetched (\(error.title))") - state = .error(error) - } - + + let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] + let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) + switch result { + case let .success(data): + log("✅ CNContact fetched") + state = .result(data) + case let .failure(error): + log("❌ CNContact not fetched (\(error.title))") + state = .error(error) + } } func getContactFromEmail(email: String, contacts: [CNContact]) -> CNContact? { diff --git a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift index c9ad11f..a7ce31c 100644 --- a/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsLists/ContactsListsViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(Contacts) -@preconcurrency import Contacts + @preconcurrency import Contacts #endif import Factory import OversizeContactsService @@ -25,17 +25,16 @@ import SwiftUI state = .loading let _ = await contactsService.requestAccess() - let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] - let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) - switch result { - case let .success(data): - log("✅ CNContact fetched") - state = .result(data) - case let .failure(error): - log("❌ CNContact not fetched (\(error.title))") - state = .error(error) - } - + let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] + let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) + switch result { + case let .success(data): + log("✅ CNContact fetched") + state = .result(data) + case let .failure(error): + log("❌ CNContact not fetched (\(error.title))") + state = .error(error) + } } func getContactFromEmail(email: String, contacts: [CNContact]) -> CNContact? { diff --git a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift index b43a1d3..243dca3 100644 --- a/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift +++ b/Sources/OversizeContactsKit/ContactsPicker/EmailPickerViewModel.swift @@ -4,7 +4,7 @@ // #if canImport(Contacts) -@preconcurrency import Contacts + @preconcurrency import Contacts #endif import Factory import OversizeContactsService @@ -27,17 +27,17 @@ import SwiftUI switch status { case .success: - let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] - let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) - switch result { - case let .success(data): - log("✅ CNContact fetched") - state = .result(data) - case let .failure(error): - log("❌ CNContact not fetched (\(error.title))") - state = .error(error) - } - + let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] + let result = await contactsService.fetchContacts(keysToFetch: keys as [CNKeyDescriptor]) + switch result { + case let .success(data): + log("✅ CNContact fetched") + state = .result(data) + case let .failure(error): + log("❌ CNContact not fetched (\(error.title))") + state = .error(error) + } + case let .failure(error): state = .error(error) } diff --git a/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift b/Sources/OversizeLocationKit/AddressPicker/AddressPickerViewModel.swift index cd32569..6db6c07 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 @@ class AddressPickerViewModel: NSObject, ObservableObject { } } -extension AddressPickerViewModel: @preconcurrency MKLocalSearchCompleterDelegate { + extension AddressPickerViewModel: @preconcurrency MKLocalSearchCompleterDelegate { func completerDidUpdateResults(_ completer: MKLocalSearchCompleter) { currentPromise?(.success(completer.results)) }