mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Clean up ahead of PR.
This commit is contained in:
parent
4e1e232825
commit
fabbe46114
1 changed files with 11 additions and 5 deletions
|
@ -4124,6 +4124,7 @@ typedef enum : NSUInteger {
|
||||||
_shouldObserveDBModifications = shouldObserveDBModifications;
|
_shouldObserveDBModifications = shouldObserveDBModifications;
|
||||||
|
|
||||||
if (self.shouldObserveDBModifications) {
|
if (self.shouldObserveDBModifications) {
|
||||||
|
DDLogVerbose(@"%@ resume observation of database modifications.", self.logTag);
|
||||||
// We need to call resetMappings when we _resume_ observing DB modifications,
|
// We need to call resetMappings when we _resume_ observing DB modifications,
|
||||||
// since we've been ignore DB modifications so the mappings can be wrong.
|
// since we've been ignore DB modifications so the mappings can be wrong.
|
||||||
//
|
//
|
||||||
|
@ -4170,15 +4171,15 @@ typedef enum : NSUInteger {
|
||||||
if (hasAddedNewItems) {
|
if (hasAddedNewItems) {
|
||||||
NSIndexPath *_Nullable indexPathToShow = [self firstIndexPathAtPreviousLastUnreadTimestamp];
|
NSIndexPath *_Nullable indexPathToShow = [self firstIndexPathAtPreviousLastUnreadTimestamp];
|
||||||
if (indexPathToShow) {
|
if (indexPathToShow) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
[self.collectionView scrollToItemAtIndexPath:indexPathToShow
|
||||||
[self.collectionView scrollToItemAtIndexPath:indexPathToShow
|
atScrollPosition:UICollectionViewScrollPositionCenteredVertically
|
||||||
atScrollPosition:UICollectionViewScrollPositionCenteredVertically
|
animated:YES];
|
||||||
animated:YES];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.previousLastUnreadTimestamp = nil;
|
self.previousLastUnreadTimestamp = nil;
|
||||||
|
DDLogVerbose(@"%@ resumed observation of database modifications.", self.logTag);
|
||||||
} else {
|
} else {
|
||||||
|
DDLogVerbose(@"%@ pausing observation of database modifications.", self.logTag);
|
||||||
// When stopping observation, try to record the timestamp of the last item.
|
// When stopping observation, try to record the timestamp of the last item.
|
||||||
//
|
//
|
||||||
// We'll use this later to update the view to reflect any changes made while
|
// We'll use this later to update the view to reflect any changes made while
|
||||||
|
@ -4200,6 +4201,7 @@ typedef enum : NSUInteger {
|
||||||
} else {
|
} else {
|
||||||
self.previousLastUnreadTimestamp = nil;
|
self.previousLastUnreadTimestamp = nil;
|
||||||
}
|
}
|
||||||
|
DDLogVerbose(@"%@ paused observation of database modifications.", self.logTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4215,6 +4217,10 @@ typedef enum : NSUInteger {
|
||||||
}
|
}
|
||||||
uint64_t previousLastUnreadTimestamp = self.previousLastUnreadTimestamp.unsignedLongLongValue;
|
uint64_t previousLastUnreadTimestamp = self.previousLastUnreadTimestamp.unsignedLongLongValue;
|
||||||
// Binary search for the first view item whose timestamp >= the "previous last unread" timestamp.
|
// Binary search for the first view item whose timestamp >= the "previous last unread" timestamp.
|
||||||
|
// We want to move "left" rightward, discarding interactions before this cutoff.
|
||||||
|
// We want to move "right" leftward, discarding all-but-the-first interaction after this cutoff.
|
||||||
|
// In the end, if we converge on an item _after_ this cutoff, it's the one we want.
|
||||||
|
// If we converge on an item _before_ this cutoff, there was no interaction that fit our criteria.
|
||||||
NSUInteger left = 0, right = self.viewItems.count - 1;
|
NSUInteger left = 0, right = self.viewItems.count - 1;
|
||||||
while (left != right) {
|
while (left != right) {
|
||||||
OWSAssert(left < right);
|
OWSAssert(left < right);
|
||||||
|
|
Loading…
Reference in a new issue