Improve Rx sequence regarding listener
This commit is contained in:
parent
6691edb59d
commit
34e8cf84dc
|
@ -54,7 +54,6 @@ class ShortcutsHandler @Inject constructor(
|
||||||
hasPinCode = pinCodeStore.getEncodedPin() != null
|
hasPinCode = pinCodeStore.getEncodedPin() != null
|
||||||
|
|
||||||
val session = activeSessionHolder.getSafeActiveSession() ?: return Disposables.empty()
|
val session = activeSessionHolder.getSafeActiveSession() ?: return Disposables.empty()
|
||||||
pinCodeStore.addListener(this)
|
|
||||||
return session.getRoomSummariesLive(
|
return session.getRoomSummariesLive(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
memberships = listOf(Membership.JOIN)
|
memberships = listOf(Membership.JOIN)
|
||||||
|
@ -62,9 +61,8 @@ class ShortcutsHandler @Inject constructor(
|
||||||
sortOrder = RoomSortOrder.PRIORITY_AND_ACTIVITY
|
sortOrder = RoomSortOrder.PRIORITY_AND_ACTIVITY
|
||||||
)
|
)
|
||||||
.asObservable()
|
.asObservable()
|
||||||
.doOnDispose {
|
.doOnSubscribe { pinCodeStore.addListener(this) }
|
||||||
pinCodeStore.removeListener(this)
|
.doFinally { pinCodeStore.removeListener(this) }
|
||||||
}
|
|
||||||
.subscribe { rooms ->
|
.subscribe { rooms ->
|
||||||
// Remove dead shortcuts (i.e. deleted rooms)
|
// Remove dead shortcuts (i.e. deleted rooms)
|
||||||
removeDeadShortcut(rooms.map { it.roomId })
|
removeDeadShortcut(rooms.map { it.roomId })
|
||||||
|
|
Loading…
Reference in New Issue