Track the user's own typing state external to the composer
Fixes https://github.com/vector-im/riot-web/issues/9986 There's a few reasons for pushing this out to its own place: * In future, we might want to move WhoIsTyping here. * We have multiple composers now, and although they don't send typing notifications, they could (see https://github.com/vector-im/riot-web/issues/10188) * In future we may have status for where/what the user is typing (https://github.com/matrix-org/matrix-doc/issues/437) * The composer is complicated enough - it doesn't need to dedupe typing states too. Note: This makes use of the principles introduced in https://github.com/vector-im/riot-web/issues/8923 and https://github.com/vector-im/riot-web/issues/9090
This commit is contained in:
parent
15d286ed93
commit
cd089a3f95
3 changed files with 86 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
Copyright 2015, 2016 OpenMarket Ltd
|
||||
Copyright 2017, 2018 New Vector Ltd
|
||||
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -61,10 +62,11 @@ import {ContentHelpers} from 'matrix-js-sdk';
|
|||
import AccessibleButton from '../elements/AccessibleButton';
|
||||
import {findEditableEvent} from '../../../utils/EventUtils';
|
||||
import ComposerHistoryManager from "../../../ComposerHistoryManager";
|
||||
import TypingStore, {TYPING_SERVER_TIMEOUT} from "../../../stores/TypingStore";
|
||||
|
||||
const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')\\s$');
|
||||
|
||||
const TYPING_USER_TIMEOUT = 10000; const TYPING_SERVER_TIMEOUT = 30000;
|
||||
const TYPING_USER_TIMEOUT = 10000;
|
||||
|
||||
// the Slate node type to default to for unstyled text
|
||||
const DEFAULT_NODE = 'paragraph';
|
||||
|
@ -477,19 +479,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
}
|
||||
|
||||
sendTyping(isTyping) {
|
||||
if (!SettingsStore.getValue('sendTypingNotifications')) return;
|
||||
if (SettingsStore.getValue('lowBandwidth')) return;
|
||||
MatrixClientPeg.get().sendTyping(
|
||||
this.props.room.roomId,
|
||||
this.isTyping, TYPING_SERVER_TIMEOUT,
|
||||
).done();
|
||||
}
|
||||
|
||||
refreshTyping() {
|
||||
if (this.typingTimeout) {
|
||||
clearTimeout(this.typingTimeout);
|
||||
this.typingTimeout = null;
|
||||
}
|
||||
TypingStore.sharedInstance().setSelfTyping(this.props.room.roomId, isTyping);
|
||||
}
|
||||
|
||||
onChange = (change: Change, originalEditorState?: Value) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue