Prefer GoogleChrome.is* over MIME.is*
		
	This commit is contained in:
		
					parent
					
						
							
								64c3d604aa
							
						
					
				
			
			
				commit
				
					
						b65370c8d7
					
				
			
		
					 4 changed files with 17 additions and 12 deletions
				
			
		| 
						 | 
					@ -17,7 +17,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  window.Whisper = window.Whisper || {};
 | 
					  window.Whisper = window.Whisper || {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const { Message, MIME } = window.Signal.Types;
 | 
					  const { Message } = window.Signal.Types;
 | 
				
			||||||
  const { upgradeMessageSchema, loadAttachmentData } = window.Signal.Migrations;
 | 
					  const { upgradeMessageSchema, loadAttachmentData } = window.Signal.Migrations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // TODO: Factor out private and group subclasses of Conversation
 | 
					  // TODO: Factor out private and group subclasses of Conversation
 | 
				
			||||||
| 
						 | 
					@ -651,7 +651,8 @@
 | 
				
			||||||
        text: quotedMessage.get('body'),
 | 
					        text: quotedMessage.get('body'),
 | 
				
			||||||
        attachments: await Promise.all((attachments || []).map(async (attachment) => {
 | 
					        attachments: await Promise.all((attachments || []).map(async (attachment) => {
 | 
				
			||||||
          const { contentType } = attachment;
 | 
					          const { contentType } = attachment;
 | 
				
			||||||
          const willMakeThumbnail = MIME.isImage(contentType);
 | 
					          const willMakeThumbnail =
 | 
				
			||||||
 | 
					            Signal.Util.GoogleChrome.isImageTypeSupported(contentType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          return {
 | 
					          return {
 | 
				
			||||||
            contentType,
 | 
					            contentType,
 | 
				
			||||||
| 
						 | 
					@ -1111,7 +1112,9 @@
 | 
				
			||||||
      const first = attachments[0];
 | 
					      const first = attachments[0];
 | 
				
			||||||
      const { thumbnail, contentType } = first;
 | 
					      const { thumbnail, contentType } = first;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return thumbnail || MIME.isVideo(contentType) || MIME.isImage(contentType);
 | 
					      return thumbnail ||
 | 
				
			||||||
 | 
					        Signal.Util.GoogleChrome.isImageTypeSupported(contentType) ||
 | 
				
			||||||
 | 
					        Signal.Util.GoogleChrome.isVideoTypeSupported(contentType);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    forceRender(message) {
 | 
					    forceRender(message) {
 | 
				
			||||||
      message.trigger('change', message);
 | 
					      message.trigger('change', message);
 | 
				
			||||||
| 
						 | 
					@ -1151,7 +1154,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Maybe in the future we could try to pull the thumbnail from a video ourselves,
 | 
					      // Maybe in the future we could try to pull the thumbnail from a video ourselves,
 | 
				
			||||||
      //   but for now we will rely on incoming thumbnails only.
 | 
					      //   but for now we will rely on incoming thumbnails only.
 | 
				
			||||||
      if (!MIME.isImage(first.contentType)) {
 | 
					      if (!Signal.Util.GoogleChrome.isImageTypeSupported(first.contentType)) {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1191,7 +1194,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Maybe in the future we could try to pull thumbnails video ourselves,
 | 
					      // Maybe in the future we could try to pull thumbnails video ourselves,
 | 
				
			||||||
      //   but for now we will rely on incoming thumbnails only.
 | 
					      //   but for now we will rely on incoming thumbnails only.
 | 
				
			||||||
      if (!first || !MIME.isImage(first.contentType)) {
 | 
					      if (!first || !Signal.Util.GoogleChrome.isImageTypeSupported(first.contentType)) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,15 +142,16 @@
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    isAudio() {
 | 
					    isAudio() {
 | 
				
			||||||
      const { contentType } = this.model;
 | 
					      const { contentType } = this.model;
 | 
				
			||||||
 | 
					      // TODO: Implement and use `Signal.Util.GoogleChrome.isAudioTypeSupported`:
 | 
				
			||||||
      return Signal.Types.MIME.isAudio(contentType);
 | 
					      return Signal.Types.MIME.isAudio(contentType);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    isVideo() {
 | 
					    isVideo() {
 | 
				
			||||||
      const { contentType } = this.model;
 | 
					      const { contentType } = this.model;
 | 
				
			||||||
      return Signal.Types.MIME.isVideo(contentType);
 | 
					      return Signal.Util.GoogleChrome.isVideoTypeSupported(contentType);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    isImage() {
 | 
					    isImage() {
 | 
				
			||||||
      const { contentType } = this.model;
 | 
					      const { contentType } = this.model;
 | 
				
			||||||
      return Signal.Types.MIME.isImage(contentType);
 | 
					      return Signal.Util.GoogleChrome.isImageTypeSupported(contentType);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mediaType() {
 | 
					    mediaType() {
 | 
				
			||||||
      if (this.isVoiceMessage()) {
 | 
					      if (this.isVoiceMessage()) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -429,7 +429,7 @@
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const first = attachments[0];
 | 
					      const first = attachments[0];
 | 
				
			||||||
      if (Signal.Types.MIME.isImage(first.contentType)) {
 | 
					      if (Signal.Util.GoogleChrome.isImageTypeSupported(first.contentType)) {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@ import React from 'react';
 | 
				
			||||||
import classnames from 'classnames';
 | 
					import classnames from 'classnames';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import * as MIME from '../../../ts/types/MIME';
 | 
					import * as MIME from '../../../ts/types/MIME';
 | 
				
			||||||
 | 
					import * as GoogleChrome from '../../../ts/util/GoogleChrome';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface Props {
 | 
					interface Props {
 | 
				
			||||||
| 
						 | 
					@ -91,12 +92,12 @@ export class Quote extends React.Component<Props, {}> {
 | 
				
			||||||
    const { contentType, thumbnail } = first;
 | 
					    const { contentType, thumbnail } = first;
 | 
				
			||||||
    const objectUrl = getObjectUrl(thumbnail);
 | 
					    const objectUrl = getObjectUrl(thumbnail);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (MIME.isVideo(contentType)) {
 | 
					    if (GoogleChrome.isVideoTypeSupported(contentType)) {
 | 
				
			||||||
      return objectUrl
 | 
					      return objectUrl
 | 
				
			||||||
        ? this.renderImage(objectUrl, 'play')
 | 
					        ? this.renderImage(objectUrl, 'play')
 | 
				
			||||||
        : this.renderIcon('movie');
 | 
					        : this.renderIcon('movie');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (MIME.isImage(contentType)) {
 | 
					    if (GoogleChrome.isImageTypeSupported(contentType)) {
 | 
				
			||||||
      return objectUrl
 | 
					      return objectUrl
 | 
				
			||||||
        ? this.renderImage(objectUrl)
 | 
					        ? this.renderImage(objectUrl)
 | 
				
			||||||
        : this.renderIcon('image');
 | 
					        : this.renderIcon('image');
 | 
				
			||||||
| 
						 | 
					@ -122,10 +123,10 @@ export class Quote extends React.Component<Props, {}> {
 | 
				
			||||||
    const first = attachments[0];
 | 
					    const first = attachments[0];
 | 
				
			||||||
    const { contentType, fileName, isVoiceMessage } = first;
 | 
					    const { contentType, fileName, isVoiceMessage } = first;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (MIME.isVideo(contentType)) {
 | 
					    if (GoogleChrome.isVideoTypeSupported(contentType)) {
 | 
				
			||||||
      return <div className="type-label">{i18n('video')}</div>;
 | 
					      return <div className="type-label">{i18n('video')}</div>;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (MIME.isImage(contentType)) {
 | 
					    if (GoogleChrome.isImageTypeSupported(contentType)) {
 | 
				
			||||||
      return <div className="type-label">{i18n('photo')}</div>;
 | 
					      return <div className="type-label">{i18n('photo')}</div>;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (MIME.isAudio(contentType) && isVoiceMessage) {
 | 
					    if (MIME.isAudio(contentType) && isVoiceMessage) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue