Implement auto mark as read for conversations
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user