catching errors when attempting to mark the current room as read
- fixes crash whilst offline
This commit is contained in:
parent
9eae45c73a
commit
ee2643c003
|
@ -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)
|
||||
|
|
|
@ -70,8 +70,10 @@ internal class MessengerViewModel(
|
|||
|
||||
private fun CoroutineScope.updateRoomReadStateAsync(latestReadEvent: EventId, state: MessengerState): Deferred<Unit> {
|
||||
return async {
|
||||
roomService.markFullyRead(state.roomState.roomOverview.roomId, latestReadEvent)
|
||||
roomStore.markRead(state.roomState.roomOverview.roomId)
|
||||
runCatching {
|
||||
roomService.markFullyRead(state.roomState.roomOverview.roomId, latestReadEvent)
|
||||
roomStore.markRead(state.roomState.roomOverview.roomId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue