From 97324eaae14d37268526c6bfef0575372602b2b8 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 30 May 2018 19:20:52 -0400 Subject: [PATCH] Load less messages initially // FREEBIE --- .../ConversationViewController.m | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 6c0414ebf..9ddd842c8 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -98,15 +98,22 @@ NS_ASSUME_NONNULL_BEGIN -// Always load up to 50 messages when user arrives. -static const int kYapDatabasePageSize = 50; -// Never show more than 50*500 = 25k messages in conversation view at a time. -static const int kYapDatabaseMaxPageCount = 500; -// Never show more than 6*50 = 300 messages in conversation view when user -// arrives. -static const int kYapDatabaseMaxInitialPageCount = 6; -static const int kConversationInitialMaxRangeSize = kYapDatabasePageSize * kYapDatabaseMaxInitialPageCount; -static const int kYapDatabaseRangeMaxLength = kYapDatabasePageSize * kYapDatabaseMaxPageCount; +// Always load up to n messages when user arrives. +// +// The smaller this number is, the faster the conversation can display. +// To test, shrink you accessability font as much as possible, then count how many 1-line system info messages (our shortest cells) can +// fit on screen at a time on an iPhoneX +// +// PERF: we could do less messages on shorter (older, slower) devices +// PERF: we could cache the cell height, since some messages will be much taller. +static const int kYapDatabasePageSize = 25; + +// Never show more than n messages in conversation view when user arrives. +static const int kConversationInitialMaxRangeSize = 300; + +// Never show more than n messages in conversation view at a time. +static const int kYapDatabaseRangeMaxLength = 25000; + static const int kYapDatabaseRangeMinLength = 0; static const CGFloat kLoadMoreHeaderHeight = 60.f;