Prechádzať zdrojové kódy

Clear typing flag when receiving message (#637)

Danilo Bargen 6 rokov pred
rodič
commit
a01ce39bbb
3 zmenil súbory, kde vykonal 10 pridanie a 7 odobranie
  1. 3 0
      src/services/webclient.ts
  2. 3 3
      src/threema.d.ts
  3. 4 4
      src/threema/container.ts

+ 3 - 0
src/services/webclient.ts

@@ -2722,6 +2722,9 @@ export class WebClientService {
                     // Try to update it first. If not, add it as a new msg.
                     if (!this.messages.update(receiver, msg)) {
                         this.messages.addNewer(receiver, [msg]);
+
+                        // If we have received a new message, it is highly unlikely that the contact is still typing
+                        this.typing.unsetTyping(receiver);
                     }
                     notify = true;
                     break;

+ 3 - 3
src/threema.d.ts

@@ -818,10 +818,10 @@ declare namespace threema {
         }
 
         interface Typing {
-            setTyping(receiver: ContactReceiver): void;
-            unsetTyping(receiver: ContactReceiver): void;
+            setTyping(receiver: BaseReceiver): void;
+            unsetTyping(receiver: BaseReceiver): void;
             clearAll(): void;
-            isTyping(receiver: ContactReceiver): boolean;
+            isTyping(receiver: BaseReceiver): boolean;
         }
 
         interface Drafts {

+ 4 - 4
src/threema/container.ts

@@ -776,15 +776,15 @@ class Converter {
 class Typing implements threema.Container.Typing {
     private set = new StringHashSet();
 
-    private getReceiverUid(receiver: threema.ContactReceiver): string {
+    private getReceiverUid(receiver: threema.BaseReceiver): string {
         return receiver.type + '-' + receiver.id;
     }
 
-    public setTyping(receiver: threema.ContactReceiver): void {
+    public setTyping(receiver: threema.BaseReceiver): void {
         this.set.add(this.getReceiverUid(receiver));
     }
 
-    public unsetTyping(receiver: threema.ContactReceiver): void {
+    public unsetTyping(receiver: threema.BaseReceiver): void {
         this.set.remove(this.getReceiverUid(receiver));
     }
 
@@ -792,7 +792,7 @@ class Typing implements threema.Container.Typing {
         this.set.clearAll();
     }
 
-    public isTyping(receiver: threema.ContactReceiver): boolean {
+    public isTyping(receiver: threema.BaseReceiver): boolean {
         return this.set.contains(this.getReceiverUid(receiver));
     }
 }