Disable typing notifications for threads (#7180)

This commit is contained in:
Germain 2021-11-23 08:25:58 +00:00 committed by GitHub
parent 87201c8bfb
commit df032b04e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 5 deletions

View file

@ -37,7 +37,7 @@ export default class TypingStore {
this.reset();
}
static sharedInstance(): TypingStore {
public static sharedInstance(): TypingStore {
if (window.mxTypingStore === undefined) {
window.mxTypingStore = new TypingStore();
}
@ -48,7 +48,7 @@ export default class TypingStore {
* Clears all cached typing states. Intended to be called when the
* MatrixClientPeg client changes.
*/
reset() {
public reset() {
this.typingStates = {
// "roomId": {
// 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 {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('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];
if ((!isTyping && !currentTyping) || (currentTyping && currentTyping.isTyping === isTyping)) {
@ -96,7 +99,7 @@ export default class TypingStore {
if (!currentTyping.userTimer.isRunning()) {
currentTyping.userTimer.restart().finished().then(() => {
this.setSelfTyping(roomId, false);
this.setSelfTyping(roomId, threadId, false);
});
} else currentTyping.userTimer.restart();
}