Skip to content
Snippets Groups Projects
Commit a35d5b95 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Refactor

parent 0c2d1aca
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!68Messenger example - send auth request
......@@ -95,7 +95,7 @@ public let userSearchReducer = Reducer<UserSearchState, UserSearchAction, UserSe
state.failure = nil
state.results = IdentifiedArray(uniqueElements: contacts.compactMap { contact in
guard let id = try? contact.getId() else { return nil }
return UserSearchResultState(id: id, contact: contact)
return UserSearchResultState(id: id, xxContact: contact)
})
return .none
......
......@@ -6,20 +6,20 @@ import XXClient
public struct UserSearchResultState: Equatable, Identifiable {
public init(
id: Data,
contact: Contact,
xxContact: Contact,
username: String? = nil,
email: String? = nil,
phone: String? = nil
) {
self.id = id
self.contact = contact
self.xxContact = xxContact
self.username = username
self.email = email
self.phone = phone
}
public var id: Data
public var contact: XXClient.Contact
public var xxContact: XXClient.Contact
public var username: String?
public var email: String?
public var phone: String?
......@@ -43,7 +43,7 @@ public let userSearchResultReducer = Reducer<UserSearchResultState, UserSearchRe
{ state, action, env in
switch action {
case .start:
let facts = (try? state.contact.getFacts()) ?? []
let facts = (try? state.xxContact.getFacts()) ?? []
state.username = facts.first(where: { $0.type == 0 })?.fact
state.email = facts.first(where: { $0.type == 1 })?.fact
state.phone = facts.first(where: { $0.type == 2 })?.fact
......
......@@ -53,7 +53,7 @@ public struct UserSearchResultView_Previews: PreviewProvider {
UserSearchResultView(store: Store(
initialState: UserSearchResultState(
id: "contact-id".data(using: .utf8)!,
contact: .unimplemented("contact-data".data(using: .utf8)!)
xxContact: .unimplemented("contact-data".data(using: .utf8)!)
),
reducer: .empty,
environment: ()
......
......@@ -53,9 +53,9 @@ final class UserSearchFeatureTests: XCTestCase {
$0.isSearching = false
$0.failure = nil
$0.results = [
.init(id: "contact-1-id".data(using: .utf8)!, contact: contact1),
.init(id: "contact-2-id".data(using: .utf8)!, contact: contact2),
.init(id: "contact-4-id".data(using: .utf8)!, contact: contact4)
.init(id: "contact-1-id".data(using: .utf8)!, xxContact: contact1),
.init(id: "contact-2-id".data(using: .utf8)!, xxContact: contact2),
.init(id: "contact-4-id".data(using: .utf8)!, xxContact: contact4)
]
}
}
......
......@@ -17,7 +17,7 @@ final class UserSearchResultFeatureTests: XCTestCase {
let store = TestStore(
initialState: UserSearchResultState(
id: "contact-id".data(using: .utf8)!,
contact: contact
xxContact: contact
),
reducer: userSearchResultReducer,
environment: .unimplemented
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment