Open message search results.
This commit is contained in:
parent
27b6a5e5bb
commit
13e9f11b4e
|
@ -1095,6 +1095,7 @@ typedef enum : NSUInteger {
|
|||
[self startReadTimer];
|
||||
[self updateNavigationBarSubtitleLabel];
|
||||
[self updateBackButtonUnreadCount];
|
||||
[self autoLoadMoreIfNecessary];
|
||||
|
||||
switch (self.actionOnOpen) {
|
||||
case ConversationViewActionNone:
|
||||
|
@ -1664,9 +1665,20 @@ typedef enum : NSUInteger {
|
|||
|
||||
if (self.lastRangeLength == 0) {
|
||||
// If this is the first time we're configuring the range length,
|
||||
// try to take into account the position of the unread indicator.
|
||||
// try to take into account the position of the unread indicator
|
||||
// and the "focus message".
|
||||
OWSAssert(self.dynamicInteractions);
|
||||
|
||||
if (self.focusMessageIdOnOpen) {
|
||||
OWSAssert(self.dynamicInteractions.focusMessagePosition);
|
||||
if (self.dynamicInteractions.focusMessagePosition) {
|
||||
DDLogVerbose(@"%@ ensuring load of focus message: %@",
|
||||
self.logTag,
|
||||
self.dynamicInteractions.focusMessagePosition);
|
||||
rangeLength = MAX(rangeLength, 1 + self.dynamicInteractions.focusMessagePosition.unsignedIntegerValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (self.dynamicInteractions.unreadIndicatorPosition) {
|
||||
NSUInteger unreadIndicatorPosition
|
||||
= (NSUInteger)[self.dynamicInteractions.unreadIndicatorPosition longValue];
|
||||
|
@ -1679,7 +1691,7 @@ typedef enum : NSUInteger {
|
|||
// We'd like to include at least N seen messages,
|
||||
// to give the user the context of where they left off the conversation.
|
||||
const NSUInteger kPreferredSeenMessageCount = 1;
|
||||
rangeLength = unreadIndicatorPosition + kPreferredSeenMessageCount;
|
||||
rangeLength = MAX(rangeLength, unreadIndicatorPosition + kPreferredSeenMessageCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2503,6 +2515,7 @@ typedef enum : NSUInteger {
|
|||
dbConnection:self.editingDatabaseConnection
|
||||
hideUnreadMessagesIndicator:self.hasClearedUnreadMessagesIndicator
|
||||
firstUnseenInteractionTimestamp:self.dynamicInteractions.firstUnseenInteractionTimestamp
|
||||
focusMessageId:self.focusMessageIdOnOpen
|
||||
maxRangeSize:maxRangeSize];
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// to include the unread indicator.
|
||||
@property (nonatomic, nullable, readonly) NSNumber *unreadIndicatorPosition;
|
||||
|
||||
@property (nonatomic, nullable, readonly) NSNumber *focusMessagePosition;
|
||||
|
||||
// If there are unseen messages in the thread, this is the timestamp
|
||||
// of the oldest unseen message.
|
||||
//
|
||||
|
@ -105,6 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
dbConnection:(YapDatabaseConnection *)dbConnection
|
||||
hideUnreadMessagesIndicator:(BOOL)hideUnreadMessagesIndicator
|
||||
firstUnseenInteractionTimestamp:(nullable NSNumber *)firstUnseenInteractionTimestamp
|
||||
focusMessageId:(nullable NSString *)focusMessageId
|
||||
maxRangeSize:(int)maxRangeSize;
|
||||
|
||||
+ (BOOL)shouldShowGroupProfileBannerInThread:(TSThread *)thread blockingManager:(OWSBlockingManager *)blockingManager;
|
||||
|
|
|
@ -31,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@property (nonatomic, nullable) NSNumber *unreadIndicatorPosition;
|
||||
|
||||
@property (nonatomic, nullable) NSNumber *focusMessagePosition;
|
||||
|
||||
@property (nonatomic, nullable) NSNumber *firstUnseenInteractionTimestamp;
|
||||
|
||||
@property (nonatomic) BOOL hasMoreUnseenMessages;
|
||||
|
@ -221,6 +223,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
hideUnreadMessagesIndicator:(BOOL)hideUnreadMessagesIndicator
|
||||
firstUnseenInteractionTimestamp:
|
||||
(nullable NSNumber *)firstUnseenInteractionTimestampParameter
|
||||
focusMessageId:(nullable NSString *)focusMessageId
|
||||
maxRangeSize:(int)maxRangeSize
|
||||
{
|
||||
OWSAssert(thread);
|
||||
|
@ -615,11 +618,46 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
indicator.timestampForSorting);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the position of the focus message _after_ performing any mutations
|
||||
// around dynamic interactions.
|
||||
if (focusMessageId != nil) {
|
||||
result.focusMessagePosition =
|
||||
[self focusMessagePositionForThread:thread transaction:transaction focusMessageId:focusMessageId];
|
||||
}
|
||||
}];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+ (nullable NSNumber *)focusMessagePositionForThread:(TSThread *)thread
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
focusMessageId:(NSString *)focusMessageId
|
||||
{
|
||||
OWSAssert(thread);
|
||||
OWSAssert(transaction);
|
||||
OWSAssert(focusMessageId);
|
||||
|
||||
// Enumerate in reverse to count the number of messages after the "focus message".
|
||||
__block NSUInteger count = 0;
|
||||
__block BOOL didMatch = NO;
|
||||
[[transaction ext:TSMessageDatabaseViewExtensionName]
|
||||
enumerateKeysInGroup:thread.uniqueId
|
||||
withOptions:NSEnumerationReverse
|
||||
usingBlock:^(NSString *collection, NSString *key, NSUInteger index, BOOL *stop) {
|
||||
if ([key isEqualToString:focusMessageId]) {
|
||||
didMatch = YES;
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
count++;
|
||||
}];
|
||||
|
||||
return didMatch ? @(count) : nil;
|
||||
}
|
||||
|
||||
+ (BOOL)shouldShowGroupProfileBannerInThread:(TSThread *)thread blockingManager:(OWSBlockingManager *)blockingManager
|
||||
{
|
||||
OWSAssert(thread);
|
||||
|
|
Loading…
Reference in New Issue