Skip to content

Commit 283d360

Browse files
author
MultiScott
committed
Fixes
1 parent 0921447 commit 283d360

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

‎Sources/ComposableContacts/Interface.swift‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ public struct ComposableContactConfig: Sendable {
179179
let historyToken: Data?
180180
/// An event visitor for enumerating and responding to change history events in the contact store.
181181
let eventVisitor: CNChangeHistoryEventVisitor
182+
183+
public init(historyToken: Data?, eventVisitor: CNChangeHistoryEventVisitor) {
184+
self.historyToken = historyToken
185+
self.eventVisitor = eventVisitor
186+
}
182187
}
183188

184189
/// A request structure specifying a contact to retrieve by its identifier along with the keys to fetch.
@@ -187,6 +192,11 @@ public struct ContactWithIdentifierRequest: Sendable {
187192
let identifier: String
188193
/// A set of `ComposableContactKey` values indicating which contact properties to fetch.
189194
let keysToFetch: Set<ComposableContactKey>
195+
196+
public init(identifier: String, keysToFetch: Set<ComposableContactKey>) {
197+
self.identifier = identifier
198+
self.keysToFetch = keysToFetch
199+
}
190200
}
191201

192202
/// A request structure for retrieving multiple contacts by their identifiers and specifying keys to fetch.
@@ -195,6 +205,11 @@ public struct ContactsWithIdentifiersRequest: Sendable {
195205
let identifiers: [String]
196206
/// A set of `ComposableContactKey` values indicating which contact properties to fetch.
197207
let keysToFetch: Set<ComposableContactKey>
208+
209+
public init(identifiers: [String], keysToFetch: Set<ComposableContactKey>) {
210+
self.identifiers = identifiers
211+
self.keysToFetch = keysToFetch
212+
}
198213
}
199214

200215
/// A request structure for retrieving contacts by a phone number.
@@ -203,6 +218,11 @@ public struct ContactsMatchingPhoneNumberRequest: Sendable {
203218
let phoneNumber: String
204219
/// A set of `ComposableContactKey` values indicating which contact properties to fetch.
205220
let keysToFetch: Set<ComposableContactKey>
221+
222+
public init(phoneNumber: String, keysToFetch: Set<ComposableContactKey>) {
223+
self.phoneNumber = phoneNumber
224+
self.keysToFetch = keysToFetch
225+
}
206226
}
207227

208228
/// A request structure for retrieving contacts by a name substring or full name.
@@ -211,6 +231,11 @@ public struct ContactsMatchingNameRequest: Sendable {
211231
let name: String
212232
/// A set of `ComposableContactKey` values indicating which contact properties to fetch.
213233
let keysToFetch: Set<ComposableContactKey>
234+
235+
public init(name: String, keysToFetch: Set<ComposableContactKey>) {
236+
self.name = name
237+
self.keysToFetch = keysToFetch
238+
}
214239
}
215240

216241
/// A request structure for retrieving contacts by an email address.
@@ -219,6 +244,11 @@ public struct ContactsMatchingEmailRequest: Sendable {
219244
let email: String
220245
/// A set of `ComposableContactKey` values indicating which contact properties to fetch.
221246
let keysToFetch: Set<ComposableContactKey>
247+
248+
public init(email: String, keysToFetch: Set<ComposableContactKey>) {
249+
self.email = email
250+
self.keysToFetch = keysToFetch
251+
}
222252
}
223253

224254
/// A request structure for retrieving contacts that belong to a specific group.
@@ -227,6 +257,11 @@ public struct ContactsInGroupRequest: Sendable {
227257
let groupID: String
228258
/// A set of `ComposableContactKey` values indicating which contact properties to fetch.
229259
let keysToFetch: Set<ComposableContactKey>
260+
261+
public init(groupID: String, keysToFetch: Set<ComposableContactKey>) {
262+
self.groupID = groupID
263+
self.keysToFetch = keysToFetch
264+
}
230265
}
231266

232267
/// A request structure for retrieving contacts in a specific container.
@@ -235,4 +270,9 @@ public struct ContactsInContainerRequest: Sendable {
235270
let containerID: String
236271
/// A set of `ComposableContactKey` values indicating which contact properties to fetch.
237272
let keysToFetch: Set<ComposableContactKey>
273+
274+
public init(containerID: String, keysToFetch: Set<ComposableContactKey>) {
275+
self.containerID = containerID
276+
self.keysToFetch = keysToFetch
277+
}
238278
}

‎Sources/ComposableContacts/LiveKey.swift‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ extension ContactsClient: DependencyKey {
3333
createNewContacts: {contacts in try await ContactActor.shared.createNewContacts(contacts: contacts)},
3434
modifyContact: {contact in try await ContactActor.shared.modifyContact(contact: contact) },
3535
modifyContacts: {contacts in try await ContactActor.shared.modifyContacts(contacts: contacts) },
36-
getAllContainers: { try await ContactActor.shared.getContainers() },
36+
getAllContainers: { try await ContactActor.shared.getAllContainers() },
3737
getContainerForContactID: {contactID in try await ContactActor.shared.getContainerForContact(with: contactID) },
3838
getContainerOfGroupWithID: {ID in try await ContactActor.shared.getContainerOfGroup(with: ID) },
3939
getContainerOfGroupsWithIDs: {IDs in try await ContactActor.shared.getContainerForGoups(with: IDs) },
40-
getAllGroups: { try await ContactActor.shared.getGroups() },
40+
getAllGroups: { try await ContactActor.shared.getAllGroups() },
4141
getAllGroupsWithIdentifiers: {IDs in try await ContactActor.shared.getGroups(with: IDs) },
4242
getAllGroupsInContainerWithID: {ID in try await ContactActor.shared.getGroupsInContainer(with: ID) }
4343
)
@@ -297,6 +297,10 @@ public final actor ContactActor {
297297
return try contactStore.containers(matching: predicate)
298298
}
299299

300+
fileprivate func getAllContainers() throws -> [CNContainer] {
301+
return try getContainers()
302+
}
303+
300304
/// Retrieves the container for a given contact.
301305
///
302306
/// - Parameter id: The identifier of the contact.
@@ -344,6 +348,10 @@ public final actor ContactActor {
344348
return try contactStore.groups(matching: predicate)
345349
}
346350

351+
fileprivate func getAllGroups() throws -> [CNGroup] {
352+
return try getGroups()
353+
}
354+
347355
/// Retrieves groups by their identifiers.
348356
///
349357
/// - Parameter identifiers: An array of group identifiers.

0 commit comments

Comments
 (0)