Private
Public Access
1
0

Implement auto mark as read for conversations

This commit is contained in:
2023-12-10 23:59:34 -08:00
parent 5a672c4b2e
commit 78efe78d4b
5 changed files with 16 additions and 0 deletions

View File

@@ -47,6 +47,9 @@ interface APIInterface {
@POST("/sendMessage")
suspend fun sendMessage(@Body request: SendMessageRequest): Response<SendMessageResponse>
@POST("/markConversation")
suspend fun markConversation(@Query("guid") conversationGUID: String): Response<Void>
}
class ResponseDecodeError(val response: ResponseBody): Exception(response.string())

View File

@@ -169,6 +169,13 @@ class ChatRepository(
_errorEncounteredChannel.emit(Error.ConnectionError(e))
}
suspend fun markConversationAsRead(conversation: Conversation) = try {
apiInterface.markConversation(conversation.guid)
} catch (e: java.lang.Exception) {
// Don't report via the channel, but log it.
Log.e(REPO_LOG, "Error marking conversation as read: ${e.message}")
}
fun close() {
database.close()
}