mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge pull request #380 from RyanRory/unread-messages-crash
Fix Crash in Very Long Conversations
This commit is contained in:
commit
e215c72912
|
@ -173,7 +173,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
static const int kYapDatabasePageSize = 100;
|
static const int kYapDatabasePageSize = 100;
|
||||||
|
|
||||||
// Never show more than n messages in conversation view when user arrives.
|
// 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.
|
// Never show more than n messages in conversation view at a time.
|
||||||
static const int kYapDatabaseRangeMaxLength = 25000;
|
static const int kYapDatabaseRangeMaxLength = 25000;
|
||||||
|
|
|
@ -169,6 +169,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
// the messages view the position of the unread indicator,
|
// the messages view the position of the unread indicator,
|
||||||
// so that it can widen its "load window" to always show
|
// so that it can widen its "load window" to always show
|
||||||
// the unread indicator.
|
// 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 long visibleUnseenMessageCount = 0;
|
||||||
__block TSInteraction *interactionAfterUnreadIndicator = nil;
|
__block TSInteraction *interactionAfterUnreadIndicator = nil;
|
||||||
__block BOOL hasMoreUnseenMessages = NO;
|
__block BOOL hasMoreUnseenMessages = NO;
|
||||||
|
@ -198,14 +204,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
visibleUnseenMessageCount++;
|
visibleUnseenMessageCount++;
|
||||||
|
|
||||||
interactionAfterUnreadIndicator = interaction;
|
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) {
|
if (!interactionAfterUnreadIndicator) {
|
||||||
|
|
Loading…
Reference in a new issue