Browse Source

Add file message preview in conversations list (#315)

Show the caption if present, fall back to filename.
Silly 8 years ago
parent
commit
a9c3014d02
1 changed files with 14 additions and 4 deletions
  1. 14 4
      src/directives/message_text.ts

+ 14 - 4
src/directives/message_text.ts

@@ -30,15 +30,25 @@ export default [
             controller: [function() {
                 // Get text depending on type
                 let rawText = null;
-                switch (this.message.type) {
+                let message = this.message as threema.Message;
+                switch (message.type) {
                     case 'text':
-                        rawText = this.message.body;
+                        rawText = message.body;
                         break;
                     case 'location':
-                        rawText = this.message.location.poi;
+                        rawText = message.location.poi;
+                        break;
+                    case 'file':
+                        // Prefer caption for file messages, if available
+                        if (message.caption !== null
+                                && message.caption.length > 0) {
+                            rawText = message.caption;
+                        } else {
+                            rawText = message.file.name;
+                        }
                         break;
                     default:
-                        rawText = this.message.caption;
+                        rawText = message.caption;
                         break;
                 }
                 // Escaping will be done in the HTML using filters