-
Notifications
You must be signed in to change notification settings - Fork 754
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
Ensure getRootSpaceSummaries()
is not called on the main thread.
#5835
Conversation
@@ -296,7 +296,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa | |||
communityGroups | |||
} | |||
.execute { async -> | |||
val rootSpaces = session.spaceService().getRootSpaceSummaries() | |||
val rootSpaces = async.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() } |
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.
On my side this is equivalent, but I do not have any spaces with child space. I will create some
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.
Ok, it works as expected
@@ -296,7 +296,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa | |||
communityGroups |
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.
should rename this to spaceList
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 agree, but I wanted to limit the number of changes for the hotfix
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.
LGTM, it's fixing freeze issues on my side
override fun getRootSpaceSummaries(): List<RoomSummary> { | ||
return roomSummaryDataSource.getRootSpaceSummaries() | ||
override suspend fun getRootSpaceSummaries(): List<RoomSummary> { | ||
return withContext(coroutineDispatchers.io) { |
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.
👍
not for this PR as it would introduce lots of changes, but worth highlighting in case we want guard against other cases
from my understanding the general approach of coroutines scoping is to define the context switching at the lowest possible level, which in this case would be
monarchy.fetchAllMappedSync
we already have a similar wrapper for awaitTransaction
this would also force non coroutine based usages to rely on runBlocking
, which would have the benefit of make finding the usages a bit easier
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 agree, good point!
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.
Actually we might want to dispatch querying db to a background thread, to avoid blocking the dispatcher, as Retrofit does for request (and probably Room)
session.accountDataService() | ||
.getLiveRoomAccountDataEvents(setOf(RoomAccountDataTypes.EVENT_TYPE_SPACE_ORDER)) | ||
.asFlow() | ||
) { _, communityGroups, _ -> |
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.
to double check, were the other flows being used as some sort of predicate? / Do we need .getLiveRoomAccountDataEvents(...).asFlow()
it's a bit strange to see us submit flows to combine
and then ignore their result 🤔
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.
It's true that we ignore the result, but we want to be notified when the account data EVENT_TYPE_SPACE_ORDER
is updated.
val rootSpaces = session.spaceService().getRootSpaceSummaries() | ||
val orders = rootSpaces.map { | ||
val rootSpaces = async.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() } | ||
val orders = rootSpaces.associate { |
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.
💯
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.
from the fix perspective LGTM! 💯 should this PR point to main
?
The PR could have pointed to |
Draft for a hotfix