Move to central MIME functions, remove some console.log
And generally address PR feedback.
This commit is contained in:
parent
f255cbcbe3
commit
fce9bb7342
6 changed files with 21 additions and 17 deletions
|
@ -1137,13 +1137,11 @@
|
||||||
|
|
||||||
// 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.
|
||||||
console.log({ first, contentType: first ? first.contentType : null });
|
|
||||||
if (!first || !MIME.isImage(first.contentType)) {
|
if (!first || !MIME.isImage(first.contentType)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const quotedAttachments = quotedMessage.get('attachments') || [];
|
const quotedAttachments = quotedMessage.get('attachments') || [];
|
||||||
console.log({ quotedMessage, quotedAttachments });
|
|
||||||
if (quotedAttachments.length === 0) {
|
if (quotedAttachments.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1155,7 +1153,6 @@
|
||||||
// Note: it would be nice to take the full-size image and downsample it into
|
// Note: it would be nice to take the full-size image and downsample it into
|
||||||
// a true thumbnail here.
|
// a true thumbnail here.
|
||||||
quotedMessage.updateImageUrl();
|
quotedMessage.updateImageUrl();
|
||||||
console.log({ quotedMessage });
|
|
||||||
},
|
},
|
||||||
async loadQuoteThumbnail(message) {
|
async loadQuoteThumbnail(message) {
|
||||||
const { quote } = message.attributes;
|
const { quote } = message.attributes;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const ESCAPE_KEY_CODE = 27;
|
const ESCAPE_KEY_CODE = 27;
|
||||||
|
const { Signal } = window;
|
||||||
|
|
||||||
const FileView = Whisper.View.extend({
|
const FileView = Whisper.View.extend({
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
|
@ -133,15 +134,16 @@
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
isAudio() {
|
isAudio() {
|
||||||
return this.model.contentType.startsWith('audio/');
|
const { contentType } = this.model;
|
||||||
|
return Signal.Types.MIME.isAudio(contentType);
|
||||||
},
|
},
|
||||||
isVideo() {
|
isVideo() {
|
||||||
const type = this.model.contentType;
|
const { contentType } = this.model;
|
||||||
return type.startsWith('video/') && type !== 'image/wmv';
|
return Signal.Types.MIME.isVideo(contentType);
|
||||||
},
|
},
|
||||||
isImage() {
|
isImage() {
|
||||||
const type = this.model.contentType;
|
const { contentType } = this.model;
|
||||||
return type.startsWith('image/') && type !== 'image/tiff';
|
return Signal.Types.MIME.isImage(contentType);
|
||||||
},
|
},
|
||||||
mediaType() {
|
mediaType() {
|
||||||
if (this.isVoiceMessage()) {
|
if (this.isVoiceMessage()) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { HTML } = window.Signal;
|
const { Signal } = window;
|
||||||
const { loadAttachmentData } = window.Signal.Migrations;
|
const { loadAttachmentData } = window.Signal.Migrations;
|
||||||
|
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
@ -401,7 +401,7 @@
|
||||||
|
|
||||||
return Object.assign({}, attachment, {
|
return Object.assign({}, attachment, {
|
||||||
// eslint-disable-next-line no-bitwise
|
// eslint-disable-next-line no-bitwise
|
||||||
isVoiceMessage: attachment.flags & VOICE_FLAG,
|
isVoiceMessage: Boolean(attachment.flags & VOICE_FLAG),
|
||||||
thumbnail,
|
thumbnail,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const first = attachments[0];
|
const first = attachments[0];
|
||||||
if (first.contentType.startsWith('image/') && first.contentType !== 'image/tiff') {
|
if (Signal.Types.MIME.isImage(first.contentType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@
|
||||||
|
|
||||||
if (body.length > 0) {
|
if (body.length > 0) {
|
||||||
const escapedBody = body.html();
|
const escapedBody = body.html();
|
||||||
body.html(HTML.render(escapedBody));
|
body.html(Signal.HTML.render(escapedBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.renderSent();
|
this.renderSent();
|
||||||
|
|
|
@ -359,9 +359,9 @@ describe('Message', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls provided async function for each quoted attachment', async () => {
|
it('calls provided async function for each quoted attachment', async () => {
|
||||||
const upgradeAttachment = sinon.stub().returns(Promise.resolve({
|
const upgradeAttachment = sinon.stub().resolves({
|
||||||
path: '/new/path/on/disk',
|
path: '/new/path/on/disk',
|
||||||
}));
|
});
|
||||||
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
|
const upgradeVersion = Message._mapQuotedAttachments(upgradeAttachment);
|
||||||
|
|
||||||
const message = {
|
const message = {
|
||||||
|
|
|
@ -24,9 +24,6 @@ window.libphonenumber = {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.Signal = {};
|
window.Signal = {};
|
||||||
window.Signal.HTML = {
|
|
||||||
render: thing => thing,
|
|
||||||
};
|
|
||||||
window.Signal.Backup = {};
|
window.Signal.Backup = {};
|
||||||
window.Signal.Crypto = {};
|
window.Signal.Crypto = {};
|
||||||
window.Signal.Logs = {};
|
window.Signal.Logs = {};
|
||||||
|
@ -54,6 +51,9 @@ window.EmojiConvertor.prototype.img_sets = {
|
||||||
|
|
||||||
window.i18n = () => '';
|
window.i18n = () => '';
|
||||||
|
|
||||||
|
// Ideally we don't need to add things here. We want to add them in StyleGuideUtil, which
|
||||||
|
// means that references to these things can't be early-bound, not capturing the direct
|
||||||
|
// reference to the function on file load.
|
||||||
window.Signal.Migrations.V17 = {};
|
window.Signal.Migrations.V17 = {};
|
||||||
window.Signal.OS = {};
|
window.Signal.OS = {};
|
||||||
window.Signal.Types = {};
|
window.Signal.Types = {};
|
||||||
|
|
|
@ -18,7 +18,10 @@ export { BackboneWrapper } from '../components/utility/BackboneWrapper';
|
||||||
// Here we can make things inside Webpack available to Backbone views like preload.js.
|
// Here we can make things inside Webpack available to Backbone views like preload.js.
|
||||||
|
|
||||||
import { Quote } from '../components/conversation/Quote';
|
import { Quote } from '../components/conversation/Quote';
|
||||||
|
import * as HTML from '../html';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
import MIME from '../../js/modules/types/mime';
|
||||||
|
|
||||||
// TypeScript wants two things when you import:
|
// TypeScript wants two things when you import:
|
||||||
// 1) a normal typescript file
|
// 1) a normal typescript file
|
||||||
|
@ -98,6 +101,8 @@ parent.moment.locale(locale);
|
||||||
parent.React = React;
|
parent.React = React;
|
||||||
parent.ReactDOM = ReactDOM;
|
parent.ReactDOM = ReactDOM;
|
||||||
|
|
||||||
|
parent.Signal.HTML = HTML;
|
||||||
|
parent.Signal.Types.MIME = MIME;
|
||||||
parent.Signal.Components = {
|
parent.Signal.Components = {
|
||||||
Quote,
|
Quote,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue