Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
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
9c1dc92c
Commit
9c1dc92c
authored
Apr 09, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix double subscriptions
parent
55509395
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
11 deletions
+20
-11
SubscriptionRepository.kt
...ual/roompark/data/data_provider/SubscriptionRepository.kt
+9
-5
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+3
-3
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+5
-2
subscriptionUseCase.kt
...to/visual/roompark/domain/use_case/subscriptionUseCase.kt
+3
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/SubscriptionRepository.kt
View file @
9c1dc92c
...
...
@@ -42,6 +42,7 @@ class SubscriptionRepository @Inject constructor(
var
sub
=
subInnerId
?.
let
{
id
->
userEntity
.
subscriptions
?.
firstOrNull
{
sub
->
sub
.
id
==
id
}
}
Timber
.
d
(
"before nullch _subsc: $sub / ${sub?.id}"
)
if
(
sub
==
null
)
{
sub
=
SubscriptionEntity
()
sub
.
setOwner
(
userEntity
)
...
...
@@ -49,8 +50,8 @@ class SubscriptionRepository @Inject constructor(
sub
.
setNumber
(
topic_id
)
}
(
sub
as
SubscriptionEntity
).
setState
(
nuewState
)
return
db
.
saveSubscription
(
sub
)
.
toObservable
()
Timber
.
d
(
"before save _subsc: $sub / ${sub?.id}"
)
return
db
.
saveSubscription
(
sub
)
}
override
fun
subscribeTopic
(
...
...
@@ -64,10 +65,11 @@ class SubscriptionRepository @Inject constructor(
deviceToken
=
deviceToken
,
topicName
=
topic
,
topicId
=
topic_id
)
.
doOnNext
{
Timber
.
d
(
"UUUUUUUU $it"
)
}
.
flatMapCompletable
{
if
(
it
.
status
==
SUBSCRIPTION_RESULT_STATUS
){
saveSubscribeState
(
user
,
subInnerId
,
topic
,
topic_id
,
true
).
ignoreElements
()
saveSubscribeState
(
user
,
subInnerId
,
topic
,
topic_id
,
true
)
.
doOnNext
{
Timber
.
d
(
"zzz $it"
)
}
.
ignoreElements
()
}
else
error
(
"Error subscription state!"
)
}
...
...
@@ -88,7 +90,9 @@ class SubscriptionRepository @Inject constructor(
.
doOnNext
{
Timber
.
d
(
"$it"
)
}
.
flatMapCompletable
{
if
(
it
.
status
==
SUBSCRIPTION_RESULT_STATUS
){
saveSubscribeState
(
user
,
subInnerId
,
topic
,
topic_id
,
false
).
ignoreElements
()
saveSubscribeState
(
user
,
subInnerId
,
topic
,
topic_id
,
false
)
.
doOnNext
{
Timber
.
d
(
"zz -z $it"
)
}
.
ignoreElements
()
}
else
error
(
"Error subscription state!"
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
9c1dc92c
...
...
@@ -16,7 +16,7 @@ import io.requery.reactivex.ReactiveScalar
* Created by Vladislav Bogdashkin on 29.10.2019.
*/
interface
IDb
{
fun
upsertUser
(
entity
:
UserEntity
):
Observable
<
UserEntity
>
?
fun
upsertUser
(
entity
:
UserEntity
):
Observable
<
UserEntity
>
fun
<
T
:
Persistable
>
upsert
(
entity
:
T
):
Single
<
T
>
fun
<
T
:
List
<
Persistable
>
>
upsert
(
entity
:
T
):
Single
<
Iterable
<
Persistable
>>
fun
fetchFeeds
():
Observable
<
FeedEntity
>
...
...
@@ -39,7 +39,7 @@ interface IDb {
fun
fetchEstateByNumber
(
building
:
Int
,
number
:
String
):
ReactiveResult
<
EstateEntity
>
fun
setArticleReadState
(
id
:
Int
,
state
:
Boolean
):
Completable
fun
setDealReadState
(
id
:
String
,
state
:
Boolean
):
Completable
fun
saveSubscription
(
subscription
:
SubscriptionEntity
):
Sing
le
<
SubscriptionEntity
>
fun
saveSubscription
(
subscription
:
SubscriptionEntity
):
Observab
le
<
SubscriptionEntity
>
fun
getSubscription
(
id
:
Int
):
ReactiveResult
<
SubscriptionEntity
>
fun
deleteTourPreview
(
id
:
String
):
Int
?
fun
deleteTourPreview
(
entity
:
TourPreviewEntity
)
...
...
@@ -53,7 +53,7 @@ interface IDb {
fun
upsertFileEntity
(
entity
:
FileEntity
):
Observable
<
FileEntity
>
fun
flowableFileEntityes
(
uris
:
List
<
RevisionString
>):
Flowable
<
FileEntity
>
fun
getDownloadedSumFileEntityes
(
uris
:
List
<
RevisionString
>):
Long
fun
fetchTouresWithStates
(
states
:
List
<
DownloadState
>):
MutableList
<
TourPreviewEntity
>
?
fun
fetchTouresWithStates
(
states
:
List
<
DownloadState
>):
MutableList
<
TourPreviewEntity
>
fun
fetchFileEntityes
(
uris
:
List
<
RevisionString
>):
MutableList
<
FileEntity
>
fun
pushFileEntities
(
uris
:
List
<
FileEntity
>):
Observable
<
Iterable
<
FileEntity
>>
fun
getFileEntity
(
uri
:
RevisionString
):
ReactiveResult
<
FileEntity
>
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
9c1dc92c
...
...
@@ -182,8 +182,11 @@ class RequeryRepository @Inject constructor(
.
single
()
.
ignoreElement
()
override
fun
saveSubscription
(
subscription
:
SubscriptionEntity
)
=
store
.
upsert
(
subscription
)
override
fun
saveSubscription
(
subscription
:
SubscriptionEntity
)
:
Observable
<
SubscriptionEntity
>
=
store
.
upsert
(
subscription
)
.
toObservable
()
.
doOnNext
{
store
.
refresh
(
subscription
.
owner
).
blockingGet
()
}
override
fun
getSubscription
(
id
:
Int
):
ReactiveResult
<
SubscriptionEntity
>
=
store
.
select
(
SubscriptionEntity
::
class
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/subscriptionUseCase.kt
View file @
9c1dc92c
...
...
@@ -92,7 +92,9 @@ class SubscriptionUseCase @Inject constructor(
sub
.
setState
(
false
)
}
Timber
.
w
(
"sub is : $sub"
)
subscription
.
saveSubscribeState
(
sub
as
SubscriptionEntity
).
blockingFirst
()
subscription
.
saveSubscribeState
(
sub
as
SubscriptionEntity
)
.
doOnNext
{
Timber
.
d
(
"zzz blocking $it"
)
}
.
blockingFirst
()
}
.
map
(
::
fromEntity
)
}
...
...
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