message_meta.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * This file is part of Threema Web.
  3. *
  4. * Threema Web is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU Affero General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or (at
  7. * your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. export default [
  18. function() {
  19. return {
  20. restrict: 'EA',
  21. transclude: true,
  22. scope: {},
  23. bindToController: {
  24. message: '=eeeMessage',
  25. },
  26. controllerAs: 'ctrl',
  27. controller: [function() {
  28. this.$onInit = function() {
  29. const msg = this.message as threema.Message;
  30. this.type = msg.type;
  31. this.isGif = msg.file !== undefined && msg.file.type === 'image/gif';
  32. // For audio, video or voip call, retrieve the duration
  33. this.duration = null;
  34. if (msg.audio !== undefined) {
  35. this.duration = msg.audio.duration;
  36. } else if (msg.video !== undefined) {
  37. this.duration = msg.video.duration;
  38. } else if (msg.voip !== undefined && msg.voip.duration) {
  39. this.duration = msg.voip.duration;
  40. }
  41. };
  42. }],
  43. template: `
  44. <span ng-if="ctrl.isGif" class="message-meta-item">GIF</span>
  45. <span ng-if="ctrl.duration" class="message-meta-item message-duration">
  46. <md-icon class="material-icons">av_timer</md-icon>
  47. {{ctrl.duration | duration}}
  48. </span>
  49. `,
  50. };
  51. },
  52. ];