properly mark read messages in the local db

This commit is contained in:
tibbi 2020-12-21 21:30:02 +01:00
parent 2f6ca40953
commit ba57fe2a22
2 changed files with 8 additions and 0 deletions

View File

@ -524,6 +524,7 @@ fun Context.markMessageRead(id: Long, isMMS: Boolean) {
val selection = "${Sms._ID} = ?" val selection = "${Sms._ID} = ?"
val selectionArgs = arrayOf(id.toString()) val selectionArgs = arrayOf(id.toString())
contentResolver.update(uri, contentValues, selection, selectionArgs) contentResolver.update(uri, contentValues, selection, selectionArgs)
messagesDB.markRead(id)
} }
fun Context.markThreadMessagesRead(threadId: Long) { fun Context.markThreadMessagesRead(threadId: Long) {
@ -536,6 +537,7 @@ fun Context.markThreadMessagesRead(threadId: Long) {
val selectionArgs = arrayOf(threadId.toString()) val selectionArgs = arrayOf(threadId.toString())
contentResolver.update(uri, contentValues, selection, selectionArgs) contentResolver.update(uri, contentValues, selection, selectionArgs)
} }
messagesDB.markThreadRead(threadId)
} }
fun Context.markThreadMessagesUnread(threadId: Long) { fun Context.markThreadMessagesUnread(threadId: Long) {

View File

@ -19,4 +19,10 @@ interface MessagesDao {
@Query("SELECT * FROM messages WHERE thread_id = :threadId") @Query("SELECT * FROM messages WHERE thread_id = :threadId")
fun getThreadMessages(threadId: Long): List<Message> fun getThreadMessages(threadId: Long): List<Message>
@Query("UPDATE messages SET read = 1 WHERE id = :id")
fun markRead(id: Long)
@Query("UPDATE messages SET read = 1 WHERE thread_id = :threadId")
fun markThreadRead(threadId: Long)
} }