mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Avoid database access on the main thread when opening the settings
`getUserProfile()` was storing the user profile (DB read, avatar Base64 encoding, DB write) on the caller dispatcher, i.e. the main thread when called from a presenter, causing glitches in the screen transition. - Run the whole `getUserProfile()` on the session dispatcher. - Make `DatabaseSessionStore` main-safe by running the queries on the IO dispatcher. - Do not refresh the profile twice from the settings screen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+8
-6
@@ -519,12 +519,14 @@ class RustMatrixClient(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getUserProfile(): Result<MatrixUser> = getProfile(sessionId)
|
||||
.onSuccess { matrixUser ->
|
||||
// Also update our session storage
|
||||
_userProfile.emit(matrixUser)
|
||||
storeUserProfile(matrixUser)
|
||||
}
|
||||
override suspend fun getUserProfile(): Result<MatrixUser> = withContext(sessionDispatcher) {
|
||||
getProfile(sessionId)
|
||||
.onSuccess { matrixUser ->
|
||||
// Also update our session storage
|
||||
_userProfile.emit(matrixUser)
|
||||
storeUserProfile(matrixUser)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the user profile in the session storage, including a base64 encoded thumbnail of the avatar,
|
||||
|
||||
Reference in New Issue
Block a user