From 9dab07f41c93dba429d7cfc366f47646015dde9e Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Tue, 6 Apr 2021 14:28:03 +1000 Subject: [PATCH 1/2] set kConversationInitialMaxRangeSize back to 100 and fix the crash --- Session/Conversations/ConversationViewModel.m | 2 +- SignalUtilitiesKit/Utilities/ThreadUtil.m | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Session/Conversations/ConversationViewModel.m b/Session/Conversations/ConversationViewModel.m index cee8ff67e..b893fe7f5 100644 --- a/Session/Conversations/ConversationViewModel.m +++ b/Session/Conversations/ConversationViewModel.m @@ -173,7 +173,7 @@ NS_ASSUME_NONNULL_BEGIN static const int kYapDatabasePageSize = 100; // Never show more than n messages in conversation view when user arrives. -static const int kConversationInitialMaxRangeSize = 25000; // TODO: Does it cause issues to set this so high? +static const int kConversationInitialMaxRangeSize = 100; // Never show more than n messages in conversation view at a time. static const int kYapDatabaseRangeMaxLength = 25000; diff --git a/SignalUtilitiesKit/Utilities/ThreadUtil.m b/SignalUtilitiesKit/Utilities/ThreadUtil.m index 68a52e67e..62a5963fe 100644 --- a/SignalUtilitiesKit/Utilities/ThreadUtil.m +++ b/SignalUtilitiesKit/Utilities/ThreadUtil.m @@ -198,14 +198,6 @@ NS_ASSUME_NONNULL_BEGIN visibleUnseenMessageCount++; interactionAfterUnreadIndicator = interaction; - - if (visibleUnseenMessageCount + 1 >= maxRangeSize) { - // If there are more unseen messages than can be displayed in the - // messages view, show the unread indicator at the top of the - // displayed messages. - *stop = YES; - hasMoreUnseenMessages = YES; - } }]; if (!interactionAfterUnreadIndicator) { From 513775b952df725ae76ba8956a2c777d3eac98fe Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Tue, 6 Apr 2021 14:32:55 +1000 Subject: [PATCH 2/2] add comments --- SignalUtilitiesKit/Utilities/ThreadUtil.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SignalUtilitiesKit/Utilities/ThreadUtil.m b/SignalUtilitiesKit/Utilities/ThreadUtil.m index 62a5963fe..bb191b0db 100644 --- a/SignalUtilitiesKit/Utilities/ThreadUtil.m +++ b/SignalUtilitiesKit/Utilities/ThreadUtil.m @@ -169,6 +169,12 @@ NS_ASSUME_NONNULL_BEGIN // the messages view the position of the unread indicator, // so that it can widen its "load window" to always show // the unread indicator. + // + // We'll load all of the unread messages. This number may be larger + // than the maxRangeSize. This is not the idealest solution for the + // crash when unread message number is over 100. We can do better if + // we just load maxRangeSize number of unread messages, but the unread + // indicator can still be at the correct position. __block long visibleUnseenMessageCount = 0; __block TSInteraction *interactionAfterUnreadIndicator = nil; __block BOOL hasMoreUnseenMessages = NO;