Disable typing notifications for threads (#7180)
This commit is contained in:
parent
87201c8bfb
commit
df032b04e0
4 changed files with 18 additions and 5 deletions
|
@ -95,6 +95,7 @@ function selectionEquals(a: Partial<Selection>, b: Selection): boolean {
|
||||||
interface IProps {
|
interface IProps {
|
||||||
model: EditorModel;
|
model: EditorModel;
|
||||||
room: Room;
|
room: Room;
|
||||||
|
threadId: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
initialCaret?: DocumentOffset;
|
initialCaret?: DocumentOffset;
|
||||||
|
@ -243,7 +244,11 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
||||||
isTyping = false;
|
isTyping = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TypingStore.sharedInstance().setSelfTyping(this.props.room.roomId, isTyping);
|
TypingStore.sharedInstance().setSelfTyping(
|
||||||
|
this.props.room.roomId,
|
||||||
|
this.props.threadId,
|
||||||
|
isTyping,
|
||||||
|
);
|
||||||
|
|
||||||
if (this.props.onChange) {
|
if (this.props.onChange) {
|
||||||
this.props.onChange();
|
this.props.onChange();
|
||||||
|
|
|
@ -535,6 +535,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
|
||||||
ref={this.editorRef}
|
ref={this.editorRef}
|
||||||
model={this.model}
|
model={this.model}
|
||||||
room={this.getRoom()}
|
room={this.getRoom()}
|
||||||
|
threadId={this.props.editState?.getEvent()?.getThread()?.id}
|
||||||
initialCaret={this.props.editState.getCaret()}
|
initialCaret={this.props.editState.getCaret()}
|
||||||
label={_t("Edit message")}
|
label={_t("Edit message")}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
|
|
|
@ -643,6 +643,9 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const threadId = this.props.relation?.rel_type === RelationType.Thread
|
||||||
|
? this.props.relation.event_id
|
||||||
|
: null;
|
||||||
return (
|
return (
|
||||||
<div className="mx_SendMessageComposer" onClick={this.focusComposer} onKeyDown={this.onKeyDown}>
|
<div className="mx_SendMessageComposer" onClick={this.focusComposer} onKeyDown={this.onKeyDown}>
|
||||||
<BasicMessageComposer
|
<BasicMessageComposer
|
||||||
|
@ -650,6 +653,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
||||||
ref={this.editorRef}
|
ref={this.editorRef}
|
||||||
model={this.model}
|
model={this.model}
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
|
threadId={threadId}
|
||||||
label={this.props.placeholder}
|
label={this.props.placeholder}
|
||||||
placeholder={this.props.placeholder}
|
placeholder={this.props.placeholder}
|
||||||
onPaste={this.onPaste}
|
onPaste={this.onPaste}
|
||||||
|
|
|
@ -37,7 +37,7 @@ export default class TypingStore {
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static sharedInstance(): TypingStore {
|
public static sharedInstance(): TypingStore {
|
||||||
if (window.mxTypingStore === undefined) {
|
if (window.mxTypingStore === undefined) {
|
||||||
window.mxTypingStore = new TypingStore();
|
window.mxTypingStore = new TypingStore();
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ export default class TypingStore {
|
||||||
* Clears all cached typing states. Intended to be called when the
|
* Clears all cached typing states. Intended to be called when the
|
||||||
* MatrixClientPeg client changes.
|
* MatrixClientPeg client changes.
|
||||||
*/
|
*/
|
||||||
reset() {
|
public reset() {
|
||||||
this.typingStates = {
|
this.typingStates = {
|
||||||
// "roomId": {
|
// "roomId": {
|
||||||
// isTyping: bool, // Whether the user is typing or not
|
// isTyping: bool, // Whether the user is typing or not
|
||||||
|
@ -63,9 +63,12 @@ export default class TypingStore {
|
||||||
* @param {string} roomId The room ID to set the typing state in.
|
* @param {string} roomId The room ID to set the typing state in.
|
||||||
* @param {boolean} isTyping Whether the user is typing or not.
|
* @param {boolean} isTyping Whether the user is typing or not.
|
||||||
*/
|
*/
|
||||||
setSelfTyping(roomId: string, isTyping: boolean): void {
|
public setSelfTyping(roomId: string, threadId: string | null, isTyping: boolean): void {
|
||||||
if (!SettingsStore.getValue('sendTypingNotifications')) return;
|
if (!SettingsStore.getValue('sendTypingNotifications')) return;
|
||||||
if (SettingsStore.getValue('lowBandwidth')) return;
|
if (SettingsStore.getValue('lowBandwidth')) return;
|
||||||
|
// Disable typing notification for threads for the initial launch
|
||||||
|
// before we figure out a better user experience for them
|
||||||
|
if (SettingsStore.getValue("feature_thread") && threadId) return;
|
||||||
|
|
||||||
let currentTyping = this.typingStates[roomId];
|
let currentTyping = this.typingStates[roomId];
|
||||||
if ((!isTyping && !currentTyping) || (currentTyping && currentTyping.isTyping === isTyping)) {
|
if ((!isTyping && !currentTyping) || (currentTyping && currentTyping.isTyping === isTyping)) {
|
||||||
|
@ -96,7 +99,7 @@ export default class TypingStore {
|
||||||
|
|
||||||
if (!currentTyping.userTimer.isRunning()) {
|
if (!currentTyping.userTimer.isRunning()) {
|
||||||
currentTyping.userTimer.restart().finished().then(() => {
|
currentTyping.userTimer.restart().finished().then(() => {
|
||||||
this.setSelfTyping(roomId, false);
|
this.setSelfTyping(roomId, threadId, false);
|
||||||
});
|
});
|
||||||
} else currentTyping.userTimer.restart();
|
} else currentTyping.userTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue