浏览代码

Fix missing translation in notification of voip status messages (#321)

Silly 8 年之前
父节点
当前提交
f6c280c82b
共有 2 个文件被更改,包括 29 次插入1 次删除
  1. 24 1
      src/services/webclient.ts
  2. 5 0
      src/threema.d.ts

+ 24 - 1
src/services/webclient.ts

@@ -2089,7 +2089,7 @@ export class WebClientService {
                     captionString = captionString + ': ' + caption;
                 }
                 let messageTypeString = this.$translate.instant('messageTypes.' + messageType);
-                switch (messageType) {
+                switch (messageType as threema.MessageType) {
                     case 'text':
                         body = message.body;
                         break;
@@ -2112,6 +2112,29 @@ export class WebClientService {
                         // TODO Show ballot title if ballot messages are implemented in the web version
                         body = messageTypeString;
                         break;
+                    case 'voipStatus':
+                        let translationKey: string;
+                        switch ((message as threema.Message).voip.status) {
+                            case 1:
+                                translationKey = 'CALL_MISSED';
+                                break;
+                            case 2:
+                                translationKey = message.isOutbox ? 'CALL_FINISHED_IN' : 'CALL_FINISHED_OUT';
+                                break;
+                            case 3:
+                                translationKey = 'CALL_REJECTED';
+                                break;
+                            case 4:
+                                translationKey = 'CALL_ABORTED';
+                                break;
+                            default:
+                                // No default
+                        }
+
+                        if (translationKey !== undefined) {
+                            body = this.$translate.instant('voip.' + translationKey);
+                        }
+                        break;
                     default:
                         // Image, video and audio
                         body = messageTypeString + captionString;

+ 5 - 0
src/threema.d.ts

@@ -80,6 +80,7 @@ declare namespace threema {
         file?: FileInfo;
         video?: VideoInfo;
         audio?: AudioInfo;
+        voip?: VoipStatusInfo;
         location?: LocationInfo;
         // only for temporary Messages
         temporaryId?: string;
@@ -103,6 +104,10 @@ declare namespace threema {
         duration: number;
     }
 
+    interface VoipStatusInfo {
+        status: number;
+    }
+
     interface LocationInfo {
         lat: number;
         lon: number;