Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
c9b65d19
Commit
c9b65d19
authored
Apr 29, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dont remove default subscriptions on result
parent
1ebfa604
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
+19
-14
AuthRepository.kt
...anto/visual/roompark/data/data_provider/AuthRepository.kt
+10
-9
SubscriptionRepository.kt
...ual/roompark/data/data_provider/SubscriptionRepository.kt
+9
-5
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/AuthRepository.kt
View file @
c9b65d19
...
...
@@ -41,15 +41,16 @@ class AuthContractModule @Inject constructor(
.
flatMap
{
db
.
upsertUser
(
it
)
}
.
flatMap
{
user
->
val
userSubs
=
user
.
subscriptions
?.
map
{
it
as
SubscriptionEntity
}
var
newSubs
=
defaultSubsList
(
user
)
if
(!
userSubs
.
isNullOrEmpty
()){
val
newSubs
=
defaultSubsList
(
user
)
.
filter
{
defSub
->
newSubs
=
newSubs
.
filter
{
defSub
->
!
userSubs
.
map
{
it
.
topic
}.
contains
(
defSub
.
topic
)
}.
toList
()
return
@flatMap
db
.
upsert
(
newSubs
)
.
toObservable
()
.
flatMap
{
db
.
refreshUser
(
user
)
}
}
else
return
@flatMap
Observable
.
just
(
user
)
if
(
newSubs
.
isNullOrEmpty
())
return
@flatMap
Observable
.
just
(
user
)
return
@flatMap
db
.
upsert
(
newSubs
)
.
toObservable
()
.
flatMap
{
db
.
refreshUser
(
user
)
}
}
.
doOnNext
{
Timber
.
d
(
"user id: ${it.uuid}"
)}
.
doOnNext
{
local
.
setRecentUser
(
it
.
uuid
.
toString
()).
blockingAwait
()
}
...
...
@@ -75,7 +76,7 @@ class AuthContractModule @Inject constructor(
}
private
fun
defaultSubsList
(
owner
:
UserEntity
)
=
arrayListOf
(
private
fun
defaultSubsList
(
owner
:
UserEntity
)
:
List
<
SubscriptionEntity
>
=
arrayListOf
(
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Progress_1
().
topicName
)
setOwner
(
owner
)
...
...
@@ -89,7 +90,7 @@ private fun defaultSubsList(owner:UserEntity) = arrayListOf(
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Progress_3
().
topicName
)
setOwner
(
owner
)
setState
(
fals
e
)
setState
(
tru
e
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Progress_kindergarden
().
topicName
)
...
...
@@ -99,7 +100,7 @@ private fun defaultSubsList(owner:UserEntity) = arrayListOf(
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
News
().
topicName
)
setOwner
(
owner
)
setState
(
fals
e
)
setState
(
tru
e
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Blog
().
topicName
)
...
...
@@ -109,6 +110,6 @@ private fun defaultSubsList(owner:UserEntity) = arrayListOf(
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Construction
().
topicName
)
setOwner
(
owner
)
setState
(
fals
e
)
setState
(
tru
e
)
}
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/data_provider/SubscriptionRepository.kt
View file @
c9b65d19
...
...
@@ -80,11 +80,15 @@ class SubscriptionRepository @Inject constructor(
cachedSub
.
setState
(
apiSub
.
active
)
newSubList
.
add
(
cachedSub
)
}
userSubs
?.
filter
{
!
newSubList
.
map
{
s
->
s
.
id
}.
contains
(
it
.
id
)
}
?.
toList
()
?.
let
{
Timber
.
w
(
"to delete; ${it.size}"
)
db
.
deleteSubscriptions
(
it
)
}
userSubs
?.
filter
{
!
newSubList
.
map
{
s
->
s
.
id
}.
contains
(
it
.
id
)
}
?.
forEach
{
(
it
as
SubscriptionEntity
).
setState
(
false
)
}
userSubs
?.
forEach
{
s
->
if
(
newSubList
.
firstOrNull
{
s
.
topic
==
it
.
topic
&&
s
.
number
==
it
.
number
}
==
null
)
newSubList
.
add
(
s
as
SubscriptionEntity
)
}
return
db
.
upsert
(
newSubList
)
.
map
{
list
->
list
.
map
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment