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
!102
Project 'elixxir/elixxir-dapps-sdk-swift' was moved to 'mobile/ios/elixxir-dapps-sdk-swift'. Please update any links and bookmarks that may still have the old path.
Release 1.0.0
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Release 1.0.0
development
into
main
Overview
0
Commits
1078
Pipelines
0
Changes
4
Merged
Dariusz Rybicki
requested to merge
development
into
main
2 years ago
Overview
0
Commits
1078
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Viewing commit
59b4b115
Show latest version
4 files
+
131
−
167
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
59b4b115
Migrate ContactsFeature to ReducerProtocol
· 59b4b115
Dariusz Rybicki
authored
2 years ago
Examples/xx-messenger/Sources/ContactsFeature/ContactsComponent.swift
0 → 100644
+
105
−
0
Options
import
AppCore
import
ComposableArchitecture
import
ComposablePresentation
import
ContactFeature
import
Foundation
import
MyContactFeature
import
XCTestDynamicOverlay
import
XXClient
import
XXMessengerClient
import
XXModels
public
struct
ContactsComponent
:
ReducerProtocol
{
public
struct
State
:
Equatable
{
public
init
(
myId
:
Data
?
=
nil
,
contacts
:
IdentifiedArrayOf
<
XXModels
.
Contact
>
=
[],
contact
:
ContactComponent
.
State
?
=
nil
,
myContact
:
MyContactComponent
.
State
?
=
nil
)
{
self
.
myId
=
myId
self
.
contacts
=
contacts
self
.
contact
=
contact
self
.
myContact
=
myContact
}
public
var
myId
:
Data
?
public
var
contacts
:
IdentifiedArrayOf
<
XXModels
.
Contact
>
public
var
contact
:
ContactComponent
.
State
?
public
var
myContact
:
MyContactComponent
.
State
?
}
public
enum
Action
:
Equatable
{
case
start
case
didFetchContacts
([
XXModels
.
Contact
])
case
contactSelected
(
XXModels
.
Contact
)
case
contactDismissed
case
contact
(
ContactComponent
.
Action
)
case
myContactSelected
case
myContactDismissed
case
myContact
(
MyContactComponent
.
Action
)
}
public
init
()
{}
@Dependency
(\
.
app
.
messenger
)
var
messenger
:
Messenger
@Dependency
(\
.
app
.
dbManager
.
getDB
)
var
db
:
DBManagerGetDB
@Dependency
(\
.
app
.
mainQueue
)
var
mainQueue
:
AnySchedulerOf
<
DispatchQueue
>
@Dependency
(\
.
app
.
bgQueue
)
var
bgQueue
:
AnySchedulerOf
<
DispatchQueue
>
public
var
body
:
some
ReducerProtocol
<
State
,
Action
>
{
Reduce
{
state
,
action
in
switch
action
{
case
.
start
:
state
.
myId
=
try
?
messenger
.
e2e
.
tryGet
()
.
getContact
()
.
getId
()
return
Effect
.
catching
{
try
db
()
}
.
flatMap
{
$0
.
fetchContactsPublisher
(
.
init
())
}
.
assertNoFailure
()
.
map
(
Action
.
didFetchContacts
)
.
subscribe
(
on
:
bgQueue
)
.
receive
(
on
:
mainQueue
)
.
eraseToEffect
()
case
.
didFetchContacts
(
var
contacts
):
if
let
myId
=
state
.
myId
,
let
myIndex
=
contacts
.
firstIndex
(
where
:
{
$0
.
id
==
myId
})
{
contacts
.
move
(
fromOffsets
:
[
myIndex
],
toOffset
:
contacts
.
startIndex
)
}
state
.
contacts
=
IdentifiedArray
(
uniqueElements
:
contacts
)
return
.
none
case
.
contactSelected
(
let
contact
):
state
.
contact
=
ContactComponent
.
State
(
id
:
contact
.
id
,
dbContact
:
contact
)
return
.
none
case
.
contactDismissed
:
state
.
contact
=
nil
return
.
none
case
.
myContactSelected
:
state
.
myContact
=
MyContactComponent
.
State
()
return
.
none
case
.
myContactDismissed
:
state
.
myContact
=
nil
return
.
none
case
.
contact
(
_
),
.
myContact
(
_
):
return
.
none
}
}
.
presenting
(
state
:
.
keyPath
(\
.
contact
),
id
:
.
keyPath
(\
.
?
.
id
),
action
:
/
Action
.
contact
,
presented
:
{
ContactComponent
()
}
)
.
presenting
(
state
:
.
keyPath
(\
.
myContact
),
id
:
.
notNil
(),
action
:
/
Action
.
myContact
,
presented
:
{
MyContactComponent
()
}
)
}
}
Loading