Ignore keyboard notifications while the view is disappearing or has disappeared.

pull/2/head
Matthew Chen 7 years ago
parent 8c345d0878
commit a7ae79aaad

@ -194,6 +194,7 @@ typedef enum : NSUInteger {
@property (nonatomic) BOOL isViewCompletelyAppeared; @property (nonatomic) BOOL isViewCompletelyAppeared;
@property (nonatomic) BOOL isViewVisible; @property (nonatomic) BOOL isViewVisible;
@property (nonatomic) BOOL isViewDisappearing;
@property (nonatomic) BOOL shouldAnimateKeyboardChanges; @property (nonatomic) BOOL shouldAnimateKeyboardChanges;
@property (nonatomic) BOOL viewHasEverAppeared; @property (nonatomic) BOOL viewHasEverAppeared;
@property (nonatomic) BOOL hasUnreadMessages; @property (nonatomic) BOOL hasUnreadMessages;
@ -737,6 +738,7 @@ typedef enum : NSUInteger {
[self hideInputIfNeeded]; [self hideInputIfNeeded];
self.isViewVisible = YES; self.isViewVisible = YES;
self.isViewDisappearing = NO;
// We should have already requested contact access at this point, so this should be a no-op // We should have already requested contact access at this point, so this should be a no-op
// unless it ever becomes possible to load this VC without going via the HomeViewController. // unless it ever becomes possible to load this VC without going via the HomeViewController.
@ -1262,17 +1264,20 @@ typedef enum : NSUInteger {
// until `viewDidDisappear`. // until `viewDidDisappear`.
- (void)viewWillDisappear:(BOOL)animated - (void)viewWillDisappear:(BOOL)animated
{ {
OWSLogDebug(@"viewWillDisappear"); OWSLogDebug(@"");
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
self.isViewCompletelyAppeared = NO; self.isViewCompletelyAppeared = NO;
self.isViewDisappearing = YES;
[self dismissMenuActions]; [self dismissMenuActions];
} }
- (void)viewDidDisappear:(BOOL)animated - (void)viewDidDisappear:(BOOL)animated
{ {
OWSLogDebug(@"");
[super viewDidDisappear:animated]; [super viewDidDisappear:animated];
self.userHasScrolled = NO; self.userHasScrolled = NO;
self.isViewVisible = NO; self.isViewVisible = NO;
@ -3828,6 +3833,15 @@ typedef enum : NSUInteger {
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
if (self.isViewDisappearing) {
// To avoid unnecessary animations, ignore keyboard notifications
// while the view is disappearing or has disappeared.
//
// This is safe; we'll always get more keyboard notifications when
// the view will re-appear.
return;
}
NSDictionary *userInfo = [notification userInfo]; NSDictionary *userInfo = [notification userInfo];
NSValue *_Nullable keyboardBeginFrameValue = userInfo[UIKeyboardFrameBeginUserInfoKey]; NSValue *_Nullable keyboardBeginFrameValue = userInfo[UIKeyboardFrameBeginUserInfoKey];

@ -115,7 +115,8 @@ public class ProfileFetcherJob: NSObject {
}.catch(on: DispatchQueue.global()) { error in }.catch(on: DispatchQueue.global()) { error in
switch error { switch error {
case ProfileFetcherJobError.throttled(let lastTimeInterval): case ProfileFetcherJobError.throttled(let lastTimeInterval):
Logger.info("skipping updateProfile: \(recipientId), lastTimeInterval: \(lastTimeInterval)") // skipping
break
case let error as SignalServiceProfile.ValidationError: case let error as SignalServiceProfile.ValidationError:
Logger.warn("skipping updateProfile retry. Invalid profile for: \(recipientId) error: \(error)") Logger.warn("skipping updateProfile retry. Invalid profile for: \(recipientId) error: \(error)")
default: default:

Loading…
Cancel
Save