Ver Fonte

Enhanced desktop notification preview (#193)

Improve preview of media messages in desktop notifications.
IndianaDschones há 8 anos atrás
pai
commit
989a51a14b
4 ficheiros alterados com 49 adições e 4 exclusões
  1. 8 1
      public/i18n/de.json
  2. 9 1
      public/i18n/en.json
  3. 3 0
      src/directives/message_icon.ts
  4. 29 2
      src/services/webclient.ts

+ 8 - 1
public/i18n/de.json

@@ -151,7 +151,14 @@
     },
     "messageTypes": {
         "AUDIO_MESSAGE": "Sprachnachricht",
-        "FILE_MESSAGE": "Datei"
+        "FILE_MESSAGE": "Datei",
+        "image": "Bild",
+        "video": "Video",
+        "file": "Datei",
+        "audio": "Sprachnachricht",
+        "location": "Ort",
+        "ballot": "Umfrage",
+        "gif": "GIF"
     },
     "validationError": {
         "createReceiver": {

+ 9 - 1
public/i18n/en.json

@@ -152,7 +152,15 @@
     },
     "messageTypes": {
         "AUDIO_MESSAGE": "Audio Message",
-        "FILE_MESSAGE": "File Message"
+        "FILE_MESSAGE": "File Message",
+        "image": "Image",
+        "video": "Video",
+        "file": "File",
+        "audio": "Audio",
+        "location": "Location",
+        "ballot": "Ballot",
+        "gif": "GIF"
+
     },
     "validationError": {
         "createReceiver": {

+ 3 - 0
src/directives/message_icon.ts

@@ -37,6 +37,9 @@ export default [
                         case 'location':
                             return 'ic_location_on_24px.svg';
                         case 'file':
+                            if (this.message.file.type === 'image/gif') {
+                                return 'ic_image_24px.svg';
+                            }
                             return 'ic_insert_drive_file_24px.svg';
                         case 'ballot':
                             return 'ic_poll_24px.svg';

+ 29 - 2
src/services/webclient.ts

@@ -2008,12 +2008,39 @@ export class WebClientService {
             .then((titlePrefix) =>  {
                 const title = `${titlePrefix} ${senderName}`;
                 let body = '';
-                switch (message.type) {
+                let messageType = message.type;
+                let caption = message.caption;
+                let captionString = '';
+                if (caption !== undefined) {
+                    captionString = captionString + ': ' + caption;
+                }
+                let messageTypeString = this.$translate.instant('messageTypes.' + messageType);
+                switch (messageType) {
                     case 'text':
                         body = message.body;
                         break;
+                    case 'location':
+                        body = messageTypeString + ': ' + message.location.poi;
+                        break;
+                    case 'file':
+                        if (message.file.type === 'image/gif') {
+                            body = this.$translate.instant('messageTypes.' + 'gif') + captionString;
+                            break;
+                        }
+                        // Display caption, if available otherwise use filename
+                        if (captionString.length > 0) {
+                            body = messageTypeString + captionString;
+                        } else {
+                            body = messageTypeString + ': ' + message.file.name;
+                        }
+                        break;
+                    case 'ballot':
+                        // TODO Show ballot title if ballot messages are implemented in the web version
+                        body = messageTypeString;
+                        break;
                     default:
-                        body = `[${message.type}]`;
+                        // Image, video and audio
+                        body = messageTypeString + captionString;
                 }
                 if (conversation.type === 'group') {
                     body = partnerName + ': ' + body;