Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change moment of displaying chat after editing existed message #30564

Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/libs/setShouldShowComposeInputKeyboardAware/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {EmitterSubscription, Keyboard} from 'react-native';
import getOperatingSystem from '@libs/getOperatingSystem';
import * as Composer from '@userActions/Composer';
import CONST from '@src/CONST';
import SetShouldShowComposeInputKeyboardAware from './types';

let keyboardDidHideListener: EmitterSubscription | null = null;
let keyboardEventListener: EmitterSubscription | null = null;
// On iOS is visible delay with displaying input after keyboard has been closed with `keyboardDidHide` event
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB

Suggested change
// On iOS is visible delay with displaying input after keyboard has been closed with `keyboardDidHide` event
// On iOS, there is a visible delay in displaying input after the keyboard has been closed with the `keyboardDidHide` event

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment fixed

// Because of that - on iOS we can use `keyboardWillHide` that is not available on android
const keyboardEvent = getOperatingSystem() === CONST.OS.IOS ? 'keyboardWillHide' : 'keyboardDidHide';
barttom marked this conversation as resolved.
Show resolved Hide resolved

const setShouldShowComposeInputKeyboardAware: SetShouldShowComposeInputKeyboardAware = (shouldShow) => {
if (keyboardDidHideListener) {
keyboardDidHideListener.remove();
keyboardDidHideListener = null;
if (keyboardEventListener) {
keyboardEventListener.remove();
keyboardEventListener = null;
}

if (!shouldShow) {
Expand All @@ -20,9 +26,9 @@ const setShouldShowComposeInputKeyboardAware: SetShouldShowComposeInputKeyboardA
return;
}

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

Expand Down
Loading