mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-14 16:25:05 +01:00
Merge pull request #4867 from nextcloud/bugfix/4866/avoidNpeInSendChatMessage
Avoid Npe in sendChatMessage
This commit is contained in:
commit
29348689a8
@ -42,6 +42,7 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.catch
|
import kotlinx.coroutines.flow.catch
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.flow.firstOrNull
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
@ -847,13 +848,17 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
.catch { e ->
|
.catch { e ->
|
||||||
Log.e(TAG, "Error when sending message", e)
|
Log.e(TAG, "Error when sending message", e)
|
||||||
|
|
||||||
val failedMessage = chatDao.getTempMessageForConversation(internalConversationId, referenceId).first()
|
val failedMessage = chatDao.getTempMessageForConversation(
|
||||||
failedMessage.sendingFailed = true
|
internalConversationId,
|
||||||
chatDao.updateChatMessage(failedMessage)
|
referenceId
|
||||||
|
).firstOrNull()
|
||||||
val failedMessageModel = failedMessage.asModel()
|
failedMessage?.let {
|
||||||
_updateMessageFlow.emit(failedMessageModel)
|
it.sendingFailed = true
|
||||||
|
chatDao.updateChatMessage(it)
|
||||||
|
|
||||||
|
val failedMessageModel = it.asModel()
|
||||||
|
_updateMessageFlow.emit(failedMessageModel)
|
||||||
|
}
|
||||||
emit(Result.failure(e))
|
emit(Result.failure(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user