-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30564 from barttom/fix/29211/remove-delay-visibil…
…ity-chat-input-after-editing-message fix: change moment of displaying chat after editing existed message
- Loading branch information
Showing
4 changed files
with
42 additions
and
29 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/libs/setShouldShowComposeInputKeyboardAware/index.android.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import setShouldShowComposeInputKeyboardAwareBuilder from './setShouldShowComposeInputKeyboardAwareBuilder'; | ||
|
||
export default setShouldShowComposeInputKeyboardAwareBuilder('keyboardDidHide'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
29
src/libs/setShouldShowComposeInputKeyboardAware/index.native.ts
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...s/setShouldShowComposeInputKeyboardAware/setShouldShowComposeInputKeyboardAwareBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |