mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Protected against crash with unread counter that exceeds thread size.
This commit is contained in:
@@ -109,10 +109,11 @@ class ConversationItemDecorations(hasWallpaper: Boolean = false, private val sch
|
|||||||
* which causes the unread divider to be removed.
|
* which causes the unread divider to be removed.
|
||||||
*/
|
*/
|
||||||
private fun updateUnreadState(items: List<ConversationElement?>) {
|
private fun updateUnreadState(items: List<ConversationElement?>) {
|
||||||
val state = unreadState
|
val state: UnreadState = unreadState
|
||||||
|
|
||||||
if (state is UnreadState.InitialUnreadState) {
|
if (state is UnreadState.InitialUnreadState) {
|
||||||
val timestamp = (items[state.unreadCount - 1] as? ConversationMessageElement)?.timestamp()
|
val firstUnread = items[(state.unreadCount - 1).coerceIn(items.indices)]
|
||||||
|
val timestamp = (firstUnread as? ConversationMessageElement)?.timestamp()
|
||||||
if (timestamp != null) {
|
if (timestamp != null) {
|
||||||
unreadState = UnreadState.CompleteUnreadState(unreadCount = state.unreadCount, firstUnreadTimestamp = timestamp)
|
unreadState = UnreadState.CompleteUnreadState(unreadCount = state.unreadCount, firstUnreadTimestamp = timestamp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3285,6 +3285,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
threadIds.forEach {
|
threadIds.forEach {
|
||||||
|
threads.updateReadState(it)
|
||||||
threads.update(
|
threads.update(
|
||||||
threadId = it,
|
threadId = it,
|
||||||
unarchive = false,
|
unarchive = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user