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]
|
## [Unreleased]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Compatibility updates for Android 15 & 16
|
- Compatibility updates for Android 15 & 16
|
||||||
- Calling now works directly without launching dialpad ([#562])
|
- Calling now works directly without launching dialpad ([#562])
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed freezing when sending messages ([#574])
|
||||||
|
|
||||||
## [1.5.0] - 2025-10-18
|
## [1.5.0] - 2025-10-18
|
||||||
### Added
|
### Added
|
||||||
- Unread badge count for conversations ([#177])
|
- 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
|
[#461]: https://github.com/FossifyOrg/Messages/issues/461
|
||||||
[#561]: https://github.com/FossifyOrg/Messages/pull/561
|
[#561]: https://github.com/FossifyOrg/Messages/pull/561
|
||||||
[#562]: https://github.com/FossifyOrg/Messages/issues/562
|
[#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
|
[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
|
[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) {
|
fun Context.markThreadMessagesRead(threadId: Long) {
|
||||||
arrayOf(Sms.CONTENT_URI, Mms.CONTENT_URI).forEach { uri ->
|
val id = threadId.toString()
|
||||||
val contentValues = ContentValues().apply {
|
|
||||||
put(Sms.READ, 1)
|
val smsValues = ContentValues().apply {
|
||||||
put(Sms.SEEN, 1)
|
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 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)
|
messagesDB.markThreadRead(threadId)
|
||||||
conversationsDB.markRead(threadId)
|
conversationsDB.markRead(threadId)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue