Skip to content

Commit

Permalink
Merge pull request Expensify#30564 from barttom/fix/29211/remove-dela…
Browse files Browse the repository at this point in the history
…y-visibility-chat-input-after-editing-message

fix: change moment of displaying chat after editing existed message
  • Loading branch information
tgolen authored Nov 7, 2023
2 parents 7457e5a + c47a6fe commit b4ee8c4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import setShouldShowComposeInputKeyboardAwareBuilder from './setShouldShowComposeInputKeyboardAwareBuilder';

export default setShouldShowComposeInputKeyboardAwareBuilder('keyboardDidHide');
5 changes: 5 additions & 0 deletions src/libs/setShouldShowComposeInputKeyboardAware/index.ios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import setShouldShowComposeInputKeyboardAwareBuilder from './setShouldShowComposeInputKeyboardAwareBuilder';

// On iOS, there is a visible delay in displaying input after the keyboard has been closed with the `keyboardDidHide` event
// Because of that - on iOS we can use `keyboardWillHide` that is not available on android
export default setShouldShowComposeInputKeyboardAwareBuilder('keyboardWillHide');
29 changes: 0 additions & 29 deletions src/libs/setShouldShowComposeInputKeyboardAware/index.native.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {EmitterSubscription, Keyboard} from 'react-native';
import {KeyboardEventName} from 'react-native/Libraries/Components/Keyboard/Keyboard';
import * as Composer from '@userActions/Composer';
import SetShouldShowComposeInputKeyboardAware from './types';

let keyboardEventListener: EmitterSubscription | null = null;
// On iOS, there is a visible delay in displaying input after the keyboard has been closed with the `keyboardDidHide` event
// Because of that - on iOS we can use `keyboardWillHide` that is not available on android

const setShouldShowComposeInputKeyboardAwareBuilder: (keyboardEvent: KeyboardEventName) => SetShouldShowComposeInputKeyboardAware =
(keyboardEvent: KeyboardEventName) => (shouldShow: boolean) => {
if (keyboardEventListener) {
keyboardEventListener.remove();
keyboardEventListener = null;
}

if (!shouldShow) {
Composer.setShouldShowComposeInput(false);
return;
}

// If keyboard is already hidden, we should show composer immediately because keyboardDidHide event won't be called
if (!Keyboard.isVisible()) {
Composer.setShouldShowComposeInput(true);
return;
}

keyboardEventListener = Keyboard.addListener(keyboardEvent, () => {
Composer.setShouldShowComposeInput(true);
keyboardEventListener?.remove();
});
};

export default setShouldShowComposeInputKeyboardAwareBuilder;

0 comments on commit b4ee8c4

Please sign in to comment.