-
Notifications
You must be signed in to change notification settings - Fork 222
Add ActiveRoomHolder
to manage the active room for a session
#4758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
1329daf
2e54b2a
0f3d2c4
9b5fa77
f7549de
51ec859
9fc2729
beb2952
ec2e448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import io.element.android.libraries.matrix.api.core.RoomId | |
import io.element.android.libraries.matrix.api.core.UserId | ||
import io.element.android.libraries.matrix.api.permalink.PermalinkData | ||
import io.element.android.libraries.matrix.api.room.JoinedRoom | ||
import io.element.android.services.appnavstate.api.ActiveRoomHolder | ||
import io.element.android.services.appnavstate.api.AppNavigationStateService | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.launch | ||
|
@@ -51,6 +52,7 @@ class JoinedRoomLoadedFlowNode @AssistedInject constructor( | |
private val appNavigationStateService: AppNavigationStateService, | ||
private val appCoroutineScope: CoroutineScope, | ||
private val matrixClient: MatrixClient, | ||
private val activeRoomHolder: ActiveRoomHolder, | ||
roomComponentFactory: RoomComponentFactory, | ||
) : BaseFlowNode<JoinedRoomLoadedFlowNode.NavTarget>( | ||
backstack = BackStack( | ||
|
@@ -85,6 +87,7 @@ class JoinedRoomLoadedFlowNode @AssistedInject constructor( | |
onCreate = { | ||
Timber.v("OnCreate => ${inputs.room.roomId}") | ||
appNavigationStateService.onNavigateToRoom(id, inputs.room.roomId) | ||
activeRoomHolder.addRoom(inputs.room) | ||
fetchRoomMembers() | ||
trackVisitedRoom() | ||
}, | ||
|
@@ -95,6 +98,7 @@ class JoinedRoomLoadedFlowNode @AssistedInject constructor( | |
}, | ||
onDestroy = { | ||
Timber.v("OnDestroy") | ||
activeRoomHolder.removeRoom(inputs.room.sessionId) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still believe that this would be useful to provide the Also one question, what will happen if there is an active call in the room, but the user closes the timeline? I guess the only issue is that there will be no cache, so not a real problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Makes sense.
I'd say nothing really. A call needs the sync to work and an active timeline to start the call, but if it's already running there should be no issues, at least with the current features. |
||
inputs.room.destroy() | ||
appNavigationStateService.onLeavingRoom(id) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import io.element.android.libraries.di.ApplicationContext | |
import io.element.android.libraries.di.SessionScope | ||
import io.element.android.libraries.matrix.api.MatrixClient | ||
import io.element.android.libraries.push.api.PushService | ||
import io.element.android.services.appnavstate.api.ActiveRoomHolder | ||
import kotlinx.coroutines.withContext | ||
import okhttp3.OkHttpClient | ||
import javax.inject.Inject | ||
|
@@ -37,8 +38,11 @@ class DefaultClearCacheUseCase @Inject constructor( | |
private val ftueService: FtueService, | ||
private val pushService: PushService, | ||
private val seenInvitesStore: SeenInvitesStore, | ||
private val activeRoomHolder: ActiveRoomHolder, | ||
) : ClearCacheUseCase { | ||
override suspend fun invoke() = withContext(coroutineDispatchers.io) { | ||
// Active rooms should be disposed of before clearing the cache | ||
activeRoomHolder.removeRoom(matrixClient.sessionId)?.destroy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that |
||
// Clear Matrix cache | ||
matrixClient.clearCache() | ||
// Clear Coil cache | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work well with permalink. If a room A opens a room B, when going back to room A, the holder will be empty.