mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-08 23:19:55 +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,
|
replyTo: Int,
|
||||||
sendWithoutNotification: Boolean,
|
sendWithoutNotification: Boolean,
|
||||||
referenceId: String
|
referenceId: String
|
||||||
): Flow<Result<ChatMessage?>> =
|
): Flow<Result<ChatMessage?>> {
|
||||||
flow {
|
if (!monitor.isOnline.first()) {
|
||||||
|
return flow {
|
||||||
|
emit(Result.failure(IOException("Skipped to send message as device is offline")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flow {
|
||||||
val response = network.sendChatMessage(
|
val response = network.sendChatMessage(
|
||||||
credentials,
|
credentials,
|
||||||
url,
|
url,
|
||||||
@ -842,6 +848,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
|
|
||||||
emit(Result.failure(e))
|
emit(Result.failure(e))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun resendChatMessage(
|
override suspend fun resendChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
@ -932,7 +939,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
it.referenceId.orEmpty()
|
it.referenceId.orEmpty()
|
||||||
).collect { result ->
|
).collect { result ->
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
Log.d(TAG, "sent temp message")
|
Log.d(TAG, "Sent temp message")
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Failed to send temp message")
|
Log.e(TAG, "Failed to send temp message")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user