Skip to content

Commit 0e4086a

Browse files
author
ignacio
committed
Fixes bug where it wouldn't be possible to dismiss the typing indicator after scrolling out from the bottom
1 parent 93c0df9 commit 0e4086a

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Source/Classes/SLKTextViewController.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,16 +1185,6 @@ - (void)didPressArrowKey:(id)sender
11851185

11861186
#pragma mark - Notification Events
11871187

1188-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
1189-
{
1190-
if ([object conformsToProtocol:@protocol(SLKTypingIndicatorProtocol)] && [keyPath isEqualToString:@"visible"]) {
1191-
[self slk_willShowOrHideTypeIndicatorView:object];
1192-
}
1193-
else {
1194-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
1195-
}
1196-
}
1197-
11981188
- (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
11991189
{
12001190
// Skips if the view isn't visible.
@@ -1385,7 +1375,7 @@ - (void)slk_didShakeTextView:(NSNotification *)notification
13851375
- (void)slk_willShowOrHideTypeIndicatorView:(UIView <SLKTypingIndicatorProtocol> *)typingIndicatorView
13861376
{
13871377
// Skips if the typing indicator should not show. Ignores the checking if it's trying to hide.
1388-
if (![self canShowTypingIndicator] && ![typingIndicatorView isVisible]) {
1378+
if (![self canShowTypingIndicator] && typingIndicatorView.isVisible) {
13891379
return;
13901380
}
13911381

@@ -1416,6 +1406,19 @@ - (void)slk_willTerminateApplication:(NSNotification *)notification
14161406
}
14171407

14181408

1409+
#pragma mark - KVO Events
1410+
1411+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
1412+
{
1413+
if ([object conformsToProtocol:@protocol(SLKTypingIndicatorProtocol)] && [keyPath isEqualToString:@"visible"]) {
1414+
[self slk_willShowOrHideTypeIndicatorView:object];
1415+
}
1416+
else {
1417+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
1418+
}
1419+
}
1420+
1421+
14191422
#pragma mark - Auto-Completion Text Processing
14201423

14211424
- (void)registerPrefixesForAutoCompletion:(NSArray *)prefixes
@@ -1941,7 +1944,6 @@ - (void)slk_registerNotifications
19411944
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(slk_didPostSLKKeyboardNotification:) name:SLKKeyboardWillHideNotification object:nil];
19421945
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(slk_didPostSLKKeyboardNotification:) name:SLKKeyboardDidHideNotification object:nil];
19431946
#endif
1944-
19451947

19461948
// TextView notifications
19471949
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(slk_willChangeTextViewText:) name:SLKTextViewTextWillChangeNotification object:nil];

Source/Classes/SLKTypingIndicatorView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ - (void)slk_commonInit
8080
- (void)setVisible:(BOOL)visible
8181
{
8282
// Skip when updating the same value, specially to avoid inovking KVO unnecessary
83-
if (visible == self.isVisible) {
83+
if (self.isVisible == visible) {
8484
return;
8585
}
8686

0 commit comments

Comments
 (0)