mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-07 06:39:45 +00:00
Skip to send message when device is offline
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
f62941f6aa
commit
cca4e69cea
@ -803,8 +803,14 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
replyTo: Int,
|
||||
sendWithoutNotification: Boolean,
|
||||
referenceId: String
|
||||
): Flow<Result<ChatMessage?>> =
|
||||
flow {
|
||||
): Flow<Result<ChatMessage?>> {
|
||||
if (!monitor.isOnline.first()) {
|
||||
return flow {
|
||||
emit(Result.failure(IOException("Skipped to send message as device is offline")))
|
||||
}
|
||||
}
|
||||
|
||||
return flow {
|
||||
val response = network.sendChatMessage(
|
||||
credentials,
|
||||
url,
|
||||
@ -842,6 +848,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
|
||||
emit(Result.failure(e))
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun resendChatMessage(
|
||||
credentials: String,
|
||||
@ -932,7 +939,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
it.referenceId.orEmpty()
|
||||
).collect { result ->
|
||||
if (result.isSuccess) {
|
||||
Log.d(TAG, "sent temp message")
|
||||
Log.d(TAG, "Sent temp message")
|
||||
} else {
|
||||
Log.e(TAG, "Failed to send temp message")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user