-
Notifications
You must be signed in to change notification settings - Fork 221
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?
Conversation
This allows us to reuse these rooms for several actions that would otherwise create a new instance of the room, which, if the room is already available, would cause delays of several seconds since the live timeline can take a while to restore if it contains many events.
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4758 +/- ##
===========================================
- Coverage 80.32% 80.32% -0.01%
===========================================
Files 2127 2128 +1
Lines 56319 56351 +32
Branches 7055 7068 +13
===========================================
+ Hits 45241 45266 +25
+ Misses 8661 8659 -2
- Partials 2417 2426 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Some remarks
class ActiveRoomHolder @Inject constructor() { | ||
private val rooms = ConcurrentHashMap<SessionId, JoinedRoom>() | ||
|
||
fun addRoom(room: JoinedRoom) { |
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.
Maybe change to setRoom
? Or store a Stack of rooms to fix the issue with permalink?
...navstate/api/src/main/kotlin/io/element/android/services/appnavstate/api/ActiveRoomHolder.kt
Outdated
Show resolved
Hide resolved
@@ -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 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.
86da4f7
to
f7549de
Compare
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.
Thanks for the update. A few more comments.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I still believe that this would be useful to provide the roomId
to the removeRoom
api, to double check that we are removing the correct room, and not the last added one.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I still believe that this would be useful to provide the roomId to the removeRoom api, to double check that we are removing the correct room, and not the last added one.
Makes sense.
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.
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.
) : 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Now that activeRoomHolder
stores a list of rooms, I think this code needs to be updated to destroy all the rooms.
* This works as a FILO (First In Last Out) stack, meaning that the last room added for a session will be the first one to be removed. | ||
*/ | ||
@SingleIn(AppScope::class) | ||
class ActiveRoomHolder @Inject constructor() { |
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.
Maybe rename to ActiveRoomsHolder
?
…d with a session before clearing the cache
… which room to remove
…nstance twice, remove outdated docs
|
Content
What the title says
Motivation and context
This allows us to reuse these rooms for several actions that would otherwise create a new instance of the room, which, if the room is already available, would cause delays of several seconds since the live timeline can take a while to restore if it contains many events.
Tests
These actions should be noticeably faster:
Tested devices
Checklist