Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #428 from slackhq/cache-fix
Browse files Browse the repository at this point in the history
Makes sure to cache text even if the view isn't visible
  • Loading branch information
sukeban committed Mar 30, 2016
2 parents 6ed26f3 + f8b94bf commit 7004cda
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1561,14 +1561,6 @@ - (void)slk_willShowOrHideTypeIndicatorView:(UIView <SLKTypingIndicatorProtocol>
}];
}

- (void)slk_willTerminateApplication:(NSNotification *)notification
{
// Caches the text before it's too late!
if (self.isViewVisible) {
[self slk_cacheTextView];
}
}


#pragma mark - KVO Events

Expand Down Expand Up @@ -2237,8 +2229,9 @@ - (void)slk_registerNotifications
[notificationCenter addObserver:self selector:@selector(slk_didShakeTextView:) name:SLKTextViewDidShakeNotification object:nil];

// Application notifications
[notificationCenter addObserver:self selector:@selector(slk_willTerminateApplication:) name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_willTerminateApplication:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_cacheTextView) name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_cacheTextView) name:UIApplicationDidEnterBackgroundNotification object:nil];
[notificationCenter addObserver:self selector:@selector(slk_cacheTextView) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
}

- (void)slk_unregisterNotifications
Expand Down Expand Up @@ -2270,6 +2263,7 @@ - (void)slk_unregisterNotifications

// Application notifications
[notificationCenter removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
[notificationCenter removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
}

Expand Down

0 comments on commit 7004cda

Please sign in to comment.