Merge branch 'charlesmchen/scrollContinuity4.2'

This commit is contained in:
Matthew Chen 2021-05-11 16:38:40 -03:00
commit 116efac9e7
3 changed files with 25 additions and 1 deletions

View File

@ -542,7 +542,13 @@ public class CVLoadCoordinator: NSObject {
let (loadPromise, loadResolver) = Promise<Void>.pending()
func canLandLoad() -> Bool {
return !delegate.isLayoutApplyingUpdate && !delegate.areCellsAnimating
AssertIsOnMainThread()
if let lastKeyboardAnimationDate = viewState.lastKeyboardAnimationDate,
lastKeyboardAnimationDate.isAfterNow {
return false
}
let result = !delegate.isLayoutApplyingUpdate && !delegate.areCellsAnimating
return result
}
func tryToResolve() {

View File

@ -151,6 +151,9 @@ public class CVViewState: NSObject {
@objc
public var currentVoiceMessageModel: VoiceMessageModel?
@objc
public var lastKeyboardAnimationDate: Date?
// MARK: -
@objc

View File

@ -3803,11 +3803,26 @@ typedef enum : NSUInteger {
- (void)handleKeyboardStateChange:(NSTimeInterval)animationDuration animationCurve:(UIViewAnimationCurve)animationCurve
{
OWSAssertIsOnMainThread();
if (self.transitionCoordinator.isInteractive) {
return;
}
if (self.shouldAnimateKeyboardChanges && animationDuration > 0) {
// Make note of when the keyboard animation will block
// loads from landing during the keyboard animation.
// It isn't safe to block loads for long, so we cap
// how long they will be blocked for.
NSTimeInterval keyboardAnimationBlockLoadInterval = kSecondInterval * 1.0;
NSDate *animationCompletionDate = [[NSDate new] dateByAddingTimeInterval:keyboardAnimationBlockLoadInterval];
NSDate *lastKeyboardAnimationDate = [[NSDate new] dateByAddingTimeInterval:-1.0];
if (self.viewState.lastKeyboardAnimationDate == nil ||
[self.viewState.lastKeyboardAnimationDate isBeforeDate:lastKeyboardAnimationDate]) {
self.viewState.lastKeyboardAnimationDate = animationCompletionDate;
self.scrollContinuity = ScrollContinuityBottom;
}
// The animation curve provided by the keyboard notifications
// is a private value not represented in UIViewAnimationOptions.
// We don't use a block based animation here because it's not