catching errors when attempting to mark the current room as read

- fixes crash whilst offline
This commit is contained in:
Adam Brown 2022-04-02 22:58:06 +01:00
parent 9eae45c73a
commit ee2643c003
2 changed files with 7 additions and 5 deletions

View File

@ -27,6 +27,9 @@ class DecryptingFetcher : Fetcher<RoomEvent.Image> {
private val http = OkHttpClient()
override suspend fun fetch(pool: BitmapPool, data: RoomEvent.Image, size: Size, options: Options): FetchResult {
val response = http.newCall(Request.Builder().url(data.imageMeta.url).build()).execute()
val outputStream = Buffer()
val keys = data.imageMeta.keys!!
val key = Base64.decode(keys.k.replace('-', '+').replace('_', '/'), Base64.DEFAULT)
val initVectorBytes = Base64.decode(keys.iv, Base64.DEFAULT)
@ -42,9 +45,6 @@ class DecryptingFetcher : Fetcher<RoomEvent.Image> {
val d = ByteArray(CRYPTO_BUFFER_SIZE)
var decodedBytes: ByteArray
val response = http.newCall(Request.Builder().url(data.imageMeta.url).build()).execute()
val outputStream = Buffer()
response.body()?.let {
it.byteStream().use {
read = it.read(d)

View File

@ -70,10 +70,12 @@ internal class MessengerViewModel(
private fun CoroutineScope.updateRoomReadStateAsync(latestReadEvent: EventId, state: MessengerState): Deferred<Unit> {
return async {
runCatching {
roomService.markFullyRead(state.roomState.roomOverview.roomId, latestReadEvent)
roomStore.markRead(state.roomState.roomOverview.roomId)
}
}
}
private fun sendMessage() {
when (val composerState = state.composerState) {