diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultGetHomeServerCapabilitiesTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultGetHomeServerCapabilitiesTask.kt
index d3cb945adb..defcfbaa81 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultGetHomeServerCapabilitiesTask.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultGetHomeServerCapabilitiesTask.kt
@@ -22,6 +22,7 @@ import im.vector.matrix.android.internal.database.model.HomeServerCapabilitiesEn
import im.vector.matrix.android.internal.database.query.getOrCreate
import im.vector.matrix.android.internal.network.executeRequest
import im.vector.matrix.android.internal.task.Task
+import im.vector.matrix.android.internal.util.awaitTransaction
import java.util.*
import javax.inject.Inject
@@ -35,7 +36,7 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
override suspend fun execute(params: Unit) {
var doRequest = false
- monarchy.doWithRealm { realm ->
+ monarchy.awaitTransaction { realm ->
val homeServerCapabilitiesEntity = HomeServerCapabilitiesEntity.getOrCreate(realm)
doRequest = homeServerCapabilitiesEntity.lastUpdatedTimestamp + MIN_DELAY_BETWEEN_TWO_REQUEST_MILLIS < Date().time
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultHomeServerCapabilitiesService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultHomeServerCapabilitiesService.kt
index 6f6416ba4a..0af849af2e 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultHomeServerCapabilitiesService.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/homeserver/DefaultHomeServerCapabilitiesService.kt
@@ -32,6 +32,13 @@ internal class DefaultHomeServerCapabilitiesService @Inject constructor(private
entity = HomeServerCapabilitiesEntity.getOrCreate(realm)
}
- return entity?.let { HomeServerCapabilitiesMapper.map(it) } ?: HomeServerCapabilities(HomeServerCapabilities.MAX_UPLOAD_FILE_SIZE_UNKNOWN)
+ return with(entity) {
+ if (this != null) {
+ HomeServerCapabilitiesMapper.map(this)
+ } else {
+ // Should not happen
+ HomeServerCapabilities(HomeServerCapabilities.MAX_UPLOAD_FILE_SIZE_UNKNOWN)
+ }
+ }
}
-}
\ No newline at end of file
+}
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt
index 7934e0ccae..7c7b90cd4b 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt
@@ -264,8 +264,8 @@ class RoomDetailFragment :
.setTitle(R.string.dialog_title_error)
.setMessage(getString(R.string.error_file_too_big,
error.filename,
- Formatter.formatFileSize(requireContext(), error.homeServerLimitInBytes),
- Formatter.formatFileSize(requireContext(), error.fileSizeInBytes)
+ Formatter.formatFileSize(requireContext(), error.fileSizeInBytes),
+ Formatter.formatFileSize(requireContext(), error.homeServerLimitInBytes)
))
.setPositiveButton(R.string.ok, null)
.show()
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt
index d31a25a8d9..f1d2431351 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt
@@ -480,10 +480,10 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
// Unknown limitation
room.sendMedias(attachments)
} else {
- attachments.find { it.size > maxUploadFileSize }
- ?.let {
- _fileTooBigEvent.postValue(LiveEvent(FileTooBigError(it.name ?: it.path, it.size, maxUploadFileSize)))
- } ?: run { room.sendMedias(attachments) }
+ when (val tooBigFile = attachments.find { it.size > maxUploadFileSize }) {
+ null -> room.sendMedias(attachments)
+ else -> _fileTooBigEvent.postValue(LiveEvent(FileTooBigError(tooBigFile.name ?: tooBigFile.path, tooBigFile.size, maxUploadFileSize)))
+ }
}
}
diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml
index 7d3312cf24..a48376e085 100644
--- a/vector/src/main/res/values/strings_riotX.xml
+++ b/vector/src/main/res/values/strings_riotX.xml
@@ -22,6 +22,6 @@
Create a new room
Close keys backup banner
- The file %1$s is too large to upload. The file size limit is %2$s but this file is %3$s.
+ "The file '%1$s' (%2$s) is too large to upload. The limit is %3$s."
\ No newline at end of file