mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 03:16:02 +03:00
Merge pull request #5405 from vector-im/cgizard/ISSUE-5402
[Create private room] Picture doesn't not displayed
This commit is contained in:
parent
1690a0b2cf
commit
2a9e582db5
4 changed files with 33 additions and 31 deletions
1
changelog.d/5402.bugfix
Normal file
1
changelog.d/5402.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
[Create room] Setting an avatar when creating a room had no effect
|
|
@ -30,6 +30,7 @@ import okhttp3.RequestBody
|
|||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okio.BufferedSink
|
||||
import okio.source
|
||||
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.failure.MatrixError
|
||||
|
@ -53,6 +54,7 @@ internal class FileUploader @Inject constructor(
|
|||
private val homeServerCapabilitiesService: HomeServerCapabilitiesService,
|
||||
private val context: Context,
|
||||
private val temporaryFileCreator: TemporaryFileCreator,
|
||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||
contentUrlResolver: ContentUrlResolver,
|
||||
moshi: Moshi
|
||||
) {
|
||||
|
@ -146,7 +148,8 @@ internal class FileUploader @Inject constructor(
|
|||
.post(requestBody)
|
||||
.build()
|
||||
|
||||
return okHttpClient.newCall(request).awaitResponse().use { response ->
|
||||
return withContext(coroutineDispatchers.io) {
|
||||
okHttpClient.newCall(request).awaitResponse().use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
throw response.toFailure(globalErrorReceiver)
|
||||
} else {
|
||||
|
@ -158,3 +161,4 @@ internal class FileUploader @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,12 +68,10 @@ internal class DefaultProfileService @Inject constructor(private val taskExecuto
|
|||
}
|
||||
|
||||
override suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String) {
|
||||
withContext(coroutineDispatchers.io) {
|
||||
val response = fileUploader.uploadFromUri(newAvatarUri, fileName, MimeTypes.Jpeg)
|
||||
setAvatarUrlTask.execute(SetAvatarUrlTask.Params(userId = userId, newAvatarUrl = response.contentUri))
|
||||
userStore.updateAvatar(userId, response.contentUri)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getAvatarUrl(userId: String): Optional<String> {
|
||||
val params = GetProfileInfoTask.Params(userId)
|
||||
|
|
|
@ -112,13 +112,13 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
|||
private suspend fun buildAvatarEvent(params: CreateRoomParams): Event? {
|
||||
return params.avatarUri?.let { avatarUri ->
|
||||
// First upload the image, ignoring any error
|
||||
tryOrNull {
|
||||
tryOrNull("Failed to upload image") {
|
||||
fileUploader.uploadFromUri(
|
||||
uri = avatarUri,
|
||||
filename = UUID.randomUUID().toString(),
|
||||
mimeType = MimeTypes.Jpeg)
|
||||
}
|
||||
?.let { response ->
|
||||
}?.let { response ->
|
||||
Event(
|
||||
type = EventType.STATE_ROOM_AVATAR,
|
||||
stateKey = "",
|
||||
|
@ -126,7 +126,6 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildHistoryVisibilityEvent(params: CreateRoomParams): Event? {
|
||||
return params.historyVisibility
|
||||
|
|
Loading…
Reference in a new issue