From 53f7ffdd624c80a8d9d0f5f42164d3b6155a39a6 Mon Sep 17 00:00:00 2001 From: wang chenyu Date: Wed, 3 Jun 2020 01:52:22 -0700 Subject: [PATCH 1/3] Avoid setting heights twice within 0.1s Fixes https://github.com/FaridSafi/react-native-gifted-chat/issues/1809 --- src/GiftedChat.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/GiftedChat.tsx b/src/GiftedChat.tsx index 6be007723..8b3498249 100644 --- a/src/GiftedChat.tsx +++ b/src/GiftedChat.tsx @@ -391,6 +391,8 @@ class GiftedChat extends React.Component< invertibleScrollViewProps: any = undefined _actionSheetRef: any = undefined + _lastUpdate = -1; + _messageContainerRef?: RefObject> = React.createRef() textInput?: any @@ -594,6 +596,11 @@ class GiftedChat extends React.Component< onKeyboardWillShow = (e: any) => { if (this.props.isKeyboardInternallyHandled) { + if (new Date().getTime() - this._lastUpdate < 100) { + return; + } + this._lastUpdate = new Date().getTime(); + this.setIsTypingDisabled(true) this.setKeyboardHeight( e.endCoordinates ? e.endCoordinates.height : e.end.height, From d5f27e84c6e916d5237b41551d11f0f9b0c19c8d Mon Sep 17 00:00:00 2001 From: wang chenyu Date: Wed, 3 Jun 2020 14:24:38 -0700 Subject: [PATCH 2/3] Update src/GiftedChat.tsx Co-authored-by: Xavier Carpentier --- src/GiftedChat.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GiftedChat.tsx b/src/GiftedChat.tsx index 8b3498249..3f57fb9cf 100644 --- a/src/GiftedChat.tsx +++ b/src/GiftedChat.tsx @@ -599,7 +599,7 @@ class GiftedChat extends React.Component< if (new Date().getTime() - this._lastUpdate < 100) { return; } - this._lastUpdate = new Date().getTime(); + this._lastUpdate = Date.now() this.setIsTypingDisabled(true) this.setKeyboardHeight( From 92fa15214f3b4ed48b4c7c79030a997174d673b1 Mon Sep 17 00:00:00 2001 From: wang chenyu Date: Wed, 3 Jun 2020 14:24:43 -0700 Subject: [PATCH 3/3] Update src/GiftedChat.tsx Co-authored-by: Xavier Carpentier --- src/GiftedChat.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GiftedChat.tsx b/src/GiftedChat.tsx index 3f57fb9cf..d09690030 100644 --- a/src/GiftedChat.tsx +++ b/src/GiftedChat.tsx @@ -596,7 +596,7 @@ class GiftedChat extends React.Component< onKeyboardWillShow = (e: any) => { if (this.props.isKeyboardInternallyHandled) { - if (new Date().getTime() - this._lastUpdate < 100) { + if (Date.now() - this._lastUpdate < 100) { return; } this._lastUpdate = Date.now()