moving the updateAvatar work to the io dispatcher

- fixes some devices/OS's from attempting to run okhttp on the main thread
This commit is contained in:
Adam Brown 2021-12-21 09:23:59 +00:00
parent 18b38fe21e
commit 7714445d24

View file

@ -68,7 +68,7 @@ internal class DefaultProfileService @Inject constructor(private val taskExecuto
} }
override suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String) { override suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String) {
withContext(coroutineDispatchers.main) { withContext(coroutineDispatchers.io) {
val response = fileUploader.uploadFromUri(newAvatarUri, fileName, MimeTypes.Jpeg) val response = fileUploader.uploadFromUri(newAvatarUri, fileName, MimeTypes.Jpeg)
setAvatarUrlTask.execute(SetAvatarUrlTask.Params(userId = userId, newAvatarUrl = response.contentUri)) setAvatarUrlTask.execute(SetAvatarUrlTask.Params(userId = userId, newAvatarUrl = response.contentUri))
userStore.updateAvatar(userId, response.contentUri) userStore.updateAvatar(userId, response.contentUri)