From 34e8cf84dc7427fe18e22a9d9ab211e2c7bb7b41 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 28 Oct 2021 09:41:27 +0200 Subject: [PATCH] Improve Rx sequence regarding listener --- .../java/im/vector/app/features/home/ShortcutsHandler.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt index f27cd30494..612e2dcf87 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt @@ -54,7 +54,6 @@ class ShortcutsHandler @Inject constructor( hasPinCode = pinCodeStore.getEncodedPin() != null val session = activeSessionHolder.getSafeActiveSession() ?: return Disposables.empty() - pinCodeStore.addListener(this) return session.getRoomSummariesLive( roomSummaryQueryParams { memberships = listOf(Membership.JOIN) @@ -62,9 +61,8 @@ class ShortcutsHandler @Inject constructor( sortOrder = RoomSortOrder.PRIORITY_AND_ACTIVITY ) .asObservable() - .doOnDispose { - pinCodeStore.removeListener(this) - } + .doOnSubscribe { pinCodeStore.addListener(this) } + .doFinally { pinCodeStore.removeListener(this) } .subscribe { rooms -> // Remove dead shortcuts (i.e. deleted rooms) removeDeadShortcut(rooms.map { it.roomId })