[FIX] Prevent mass is typing dispatchs (#651)
This commit is contained in:
parent
a1f49d7127
commit
bf212bfc4d
|
@ -216,7 +216,7 @@ dependencies {
|
|||
implementation 'com.facebook.fresco:animated-gif:1.10.0'
|
||||
implementation 'com.facebook.fresco:animated-webp:1.10.0'
|
||||
implementation 'com.facebook.fresco:webpsupport:1.10.0'
|
||||
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
|
||||
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
|
||||
implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
|
||||
transitive = true;
|
||||
}
|
||||
|
|
|
@ -155,10 +155,8 @@ export default class MessageBox extends Component {
|
|||
}
|
||||
|
||||
onChangeText(text) {
|
||||
const { typing } = this.props;
|
||||
|
||||
this.setInput(text);
|
||||
typing(text.length > 0);
|
||||
this.handleTyping(text.length > 0);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
const { start, end } = this.component._lastNativeSelection;
|
||||
|
@ -420,6 +418,27 @@ export default class MessageBox extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
handleTyping = (isTyping) => {
|
||||
const { typing } = this.props;
|
||||
if (!isTyping) {
|
||||
if (this.typingTimeout) {
|
||||
clearTimeout(this.typingTimeout);
|
||||
this.typingTimeout = false;
|
||||
}
|
||||
typing(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.typingTimeout) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.typingTimeout = setTimeout(() => {
|
||||
typing(true);
|
||||
this.typingTimeout = false;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
setInput = (text) => {
|
||||
this.text = text;
|
||||
this.component.setNativeProps({ text });
|
||||
|
@ -516,14 +535,14 @@ export default class MessageBox extends Component {
|
|||
|
||||
submit = async() => {
|
||||
const {
|
||||
typing, message: editingMessage, editRequest, onSubmit
|
||||
message: editingMessage, editRequest, onSubmit
|
||||
} = this.props;
|
||||
const message = this.text;
|
||||
|
||||
this.clearInput();
|
||||
this.closeEmoji();
|
||||
this.stopTrackingMention();
|
||||
typing(false);
|
||||
this.handleTyping(false);
|
||||
if (message.trim() === '') {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue