perf: improve mark as read performance (#584)
Refs: https://github.com/FossifyOrg/Messages/issues/574
This commit is contained in:
parent
893fb3c2f9
commit
07b7e92d82
2 changed files with 21 additions and 9 deletions
|
|
@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Compatibility updates for Android 15 & 16
|
||||
- Calling now works directly without launching dialpad ([#562])
|
||||
|
||||
### Fixed
|
||||
- Fixed freezing when sending messages ([#574])
|
||||
|
||||
## [1.5.0] - 2025-10-18
|
||||
### Added
|
||||
- Unread badge count for conversations ([#177])
|
||||
|
|
@ -194,6 +196,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#461]: https://github.com/FossifyOrg/Messages/issues/461
|
||||
[#561]: https://github.com/FossifyOrg/Messages/pull/561
|
||||
[#562]: https://github.com/FossifyOrg/Messages/issues/562
|
||||
[#574]: https://github.com/FossifyOrg/Messages/issues/574
|
||||
|
||||
[Unreleased]: https://github.com/FossifyOrg/Messages/compare/1.5.0...HEAD
|
||||
[1.5.0]: https://github.com/FossifyOrg/Messages/compare/1.4.0...1.5.0
|
||||
|
|
|
|||
|
|
@ -994,15 +994,24 @@ fun Context.markMessageRead(id: Long, isMMS: Boolean) {
|
|||
}
|
||||
|
||||
fun Context.markThreadMessagesRead(threadId: Long) {
|
||||
arrayOf(Sms.CONTENT_URI, Mms.CONTENT_URI).forEach { uri ->
|
||||
val contentValues = ContentValues().apply {
|
||||
put(Sms.READ, 1)
|
||||
put(Sms.SEEN, 1)
|
||||
}
|
||||
val selection = "${Sms.THREAD_ID} = ?"
|
||||
val selectionArgs = arrayOf(threadId.toString())
|
||||
contentResolver.update(uri, contentValues, selection, selectionArgs)
|
||||
val id = threadId.toString()
|
||||
|
||||
val smsValues = ContentValues().apply {
|
||||
put(Sms.READ, 1)
|
||||
put(Sms.SEEN, 1)
|
||||
}
|
||||
val smsSelection = "${Sms.THREAD_ID}=? AND ${Sms.TYPE}=? AND (${Sms.READ}=? OR ${Sms.SEEN}=?)"
|
||||
val smsArgs = arrayOf(id, Sms.MESSAGE_TYPE_INBOX.toString(), "0", "0")
|
||||
contentResolver.update(Sms.CONTENT_URI, smsValues, smsSelection, smsArgs)
|
||||
|
||||
val mmsValues = ContentValues().apply {
|
||||
put(Mms.READ, 1)
|
||||
put(Mms.SEEN, 1)
|
||||
}
|
||||
val mmsSelection = "${Mms.THREAD_ID}=? AND ${Mms.MESSAGE_BOX}=? AND (${Mms.READ}=? OR ${Mms.SEEN}=?)"
|
||||
val mmsArgs = arrayOf(id, Mms.MESSAGE_BOX_INBOX.toString(), "0", "0")
|
||||
contentResolver.update(Mms.CONTENT_URI, mmsValues, mmsSelection, mmsArgs)
|
||||
|
||||
messagesDB.markThreadRead(threadId)
|
||||
conversationsDB.markRead(threadId)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue