From a856415438d92142e9e85dbcabd713a934497ccd Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Thu, 30 Sep 2021 10:53:13 +1000 Subject: [PATCH] fix conversation screen unread count > viewItems count crash --- Session/Conversations/ConversationVC.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index cc4445e25..5acfbb65b 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -167,7 +167,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat Storage.read { transaction in unreadCount = self.thread.unreadMessageCount(transaction: transaction) } - let clampedUnreadCount = min(unreadCount, UInt(kConversationInitialMaxRangeSize)) + let clampedUnreadCount = min(unreadCount, UInt(kConversationInitialMaxRangeSize), UInt(viewItems.endIndex)) unreadViewItems = clampedUnreadCount != 0 ? [ConversationViewItem](viewItems[viewItems.endIndex - Int(clampedUnreadCount) ..< viewItems.endIndex]) : [] }