Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Merge requests
!112
Restore contacts from backup
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Restore contacts from backup
feature/restore-contacts-from-backup
into
development
Overview
0
Commits
26
Pipelines
0
Changes
2
Merged
Dariusz Rybicki
requested to merge
feature/restore-contacts-from-backup
into
development
2 years ago
Overview
0
Commits
26
Pipelines
0
Changes
2
Expand
XXClient library
Improve error handling in
UdMultiLookupCallback
.
xx-messenger example
Improve backup restoration.
Restore contacts.
Add contact lookup feature.
Display contact ids.
Improve sending requests.
Restore username from restored facts, not from restored params.
Edited
2 years ago
by
Dariusz Rybicki
0
0
Merge request reports
Viewing commit
5eda3f48
Prev
Next
Show latest version
2 files
+
7
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
5eda3f48
Improve failure handling in ContactLookupFeature
· 5eda3f48
Dariusz Rybicki
authored
2 years ago
Examples/xx-messenger/Sources/ContactLookupFeature/ContactLookupFeature.swift
0 → 100644
+
83
−
0
Options
import
ComposableArchitecture
import
Foundation
import
XCTestDynamicOverlay
import
XXClient
import
XXMessengerClient
public
struct
ContactLookupState
:
Equatable
{
public
init
(
id
:
Data
,
isLookingUp
:
Bool
=
false
,
failure
:
String
?
=
nil
)
{
self
.
id
=
id
self
.
isLookingUp
=
isLookingUp
self
.
failure
=
failure
}
public
var
id
:
Data
public
var
isLookingUp
:
Bool
public
var
failure
:
String
?
}
public
enum
ContactLookupAction
:
Equatable
{
case
lookupTapped
case
didLookup
(
XXClient
.
Contact
)
case
didFail
(
NSError
)
}
public
struct
ContactLookupEnvironment
{
public
init
(
messenger
:
Messenger
,
mainQueue
:
AnySchedulerOf
<
DispatchQueue
>
,
bgQueue
:
AnySchedulerOf
<
DispatchQueue
>
)
{
self
.
messenger
=
messenger
self
.
mainQueue
=
mainQueue
self
.
bgQueue
=
bgQueue
}
public
var
messenger
:
Messenger
public
var
mainQueue
:
AnySchedulerOf
<
DispatchQueue
>
public
var
bgQueue
:
AnySchedulerOf
<
DispatchQueue
>
}
#if DEBUG
extension
ContactLookupEnvironment
{
public
static
let
unimplemented
=
ContactLookupEnvironment
(
messenger
:
.
unimplemented
,
mainQueue
:
.
unimplemented
,
bgQueue
:
.
unimplemented
)
}
#endif
public
let
contactLookupReducer
=
Reducer
<
ContactLookupState
,
ContactLookupAction
,
ContactLookupEnvironment
>
{
state
,
action
,
env
in
switch
action
{
case
.
lookupTapped
:
state
.
isLookingUp
=
true
state
.
failure
=
nil
return
Effect
.
result
{
[
state
]
in
do
{
let
contact
=
try
env
.
messenger
.
lookupContact
(
id
:
state
.
id
)
return
.
success
(
.
didLookup
(
contact
))
}
catch
{
return
.
success
(
.
didFail
(
error
as
NSError
))
}
}
.
subscribe
(
on
:
env
.
bgQueue
)
.
receive
(
on
:
env
.
mainQueue
)
.
eraseToEffect
()
case
.
didLookup
(
_
):
state
.
isLookingUp
=
false
state
.
failure
=
nil
return
.
none
case
.
didFail
(
let
error
):
state
.
isLookingUp
=
false
state
.
failure
=
error
.
localizedDescription
return
.
none
}
}
Loading