Responding to pull request review feedback
- messages.getQuoteObjectUrl: early return - backup.js: explaining variables for long if statement - types/messages.js: Log if thumbnail has neither data nor path - sendmessage.js: - remove extraneous logging - fix indentation - upload attachments and thumbnails in parallel - preload: don't load fs for tests, just fse - _conversation.scss: split two selectors into two lines, 0px -> 0 - backup_test.js: use fse.existsSync and comment twoSlashes regex - network_tests_view_test.js: Comment duplicate assignment to window.getSocketStatus
This commit is contained in:
parent
6ec6bf08c8
commit
c02860af5c
8 changed files with 34 additions and 18 deletions
|
@ -214,11 +214,11 @@
|
||||||
},
|
},
|
||||||
getQuoteObjectUrl() {
|
getQuoteObjectUrl() {
|
||||||
const thumbnail = this.quoteThumbnail;
|
const thumbnail = this.quoteThumbnail;
|
||||||
if (thumbnail && thumbnail.objectUrl) {
|
if (!thumbnail || !thumbnail.objectUrl) {
|
||||||
return thumbnail.objectUrl;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return thumbnail.objectUrl;
|
||||||
},
|
},
|
||||||
getQuoteContact() {
|
getQuoteContact() {
|
||||||
const quote = this.get('quote');
|
const quote = this.get('quote');
|
||||||
|
|
|
@ -1030,8 +1030,11 @@ async function importConversation(db, dir, options) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((message.attachments && message.attachments.length) ||
|
const hasAttachments = message.attachments && message.attachments.length;
|
||||||
(message.quote && message.quote.attachments && message.quote.attachments.length)) {
|
const hasQuotedAttachments = message.quote && message.quote.attachments &&
|
||||||
|
message.quote.attachments.length > 0;
|
||||||
|
|
||||||
|
if (hasAttachments || hasQuotedAttachments) {
|
||||||
const importMessage = async () => {
|
const importMessage = async () => {
|
||||||
const getName = attachmentsDir
|
const getName = attachmentsDir
|
||||||
? _getAnonymousAttachmentFileName
|
? _getAnonymousAttachmentFileName
|
||||||
|
|
|
@ -274,6 +274,13 @@ exports.createAttachmentDataWriter = (writeExistingAttachmentData) => {
|
||||||
|
|
||||||
// we want to be bulletproof to thumbnails without data
|
// we want to be bulletproof to thumbnails without data
|
||||||
if (!data || !path) {
|
if (!data || !path) {
|
||||||
|
console.log(
|
||||||
|
'Thumbnail had neither data nor path.',
|
||||||
|
'id:',
|
||||||
|
message.id,
|
||||||
|
'source:',
|
||||||
|
message.source
|
||||||
|
);
|
||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,11 +97,10 @@ Message.prototype = {
|
||||||
if (this.quote) {
|
if (this.quote) {
|
||||||
var QuotedAttachment = textsecure.protobuf.DataMessage.Quote.QuotedAttachment;
|
var QuotedAttachment = textsecure.protobuf.DataMessage.Quote.QuotedAttachment;
|
||||||
var Quote = textsecure.protobuf.DataMessage.Quote;
|
var Quote = textsecure.protobuf.DataMessage.Quote;
|
||||||
console.log(this.quote);
|
|
||||||
|
|
||||||
proto.quote = new Quote();
|
proto.quote = new Quote();
|
||||||
|
var quote = proto.quote;
|
||||||
|
|
||||||
var quote = proto.quote;
|
|
||||||
quote.id = this.quote.id;
|
quote.id = this.quote.id;
|
||||||
quote.author = this.quote.author;
|
quote.author = this.quote.author;
|
||||||
quote.text = this.quote.text;
|
quote.text = this.quote.text;
|
||||||
|
@ -289,9 +288,10 @@ MessageSender.prototype = {
|
||||||
|
|
||||||
sendMessage: function(attrs) {
|
sendMessage: function(attrs) {
|
||||||
var message = new Message(attrs);
|
var message = new Message(attrs);
|
||||||
return this.uploadAttachments(message).then(function() {
|
return Promise.all([
|
||||||
return this.uploadThumbnails(message);
|
this.uploadAttachments(message),
|
||||||
}.bind(this)).then(function() {
|
this.uploadThumbnails(message),
|
||||||
|
]).then(function() {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
this.sendMessageProto(
|
this.sendMessageProto(
|
||||||
message.timestamp,
|
message.timestamp,
|
||||||
|
|
|
@ -209,7 +209,6 @@ require('./js/spell_check');
|
||||||
if (window.config.environment === 'test') {
|
if (window.config.environment === 'test') {
|
||||||
/* eslint-disable global-require, import/no-extraneous-dependencies */
|
/* eslint-disable global-require, import/no-extraneous-dependencies */
|
||||||
window.test = {
|
window.test = {
|
||||||
fs: require('fs'),
|
|
||||||
glob: require('glob'),
|
glob: require('glob'),
|
||||||
fse: require('fs-extra'),
|
fse: require('fs-extra'),
|
||||||
tmp: require('tmp'),
|
tmp: require('tmp'),
|
||||||
|
|
|
@ -869,12 +869,13 @@ span.status {
|
||||||
|
|
||||||
// We only add margin if there's no 'sender' element beforehand, which is only possible
|
// We only add margin if there's no 'sender' element beforehand, which is only possible
|
||||||
// on incoming messages, and only in groups (when we're not in a .private conversation).
|
// on incoming messages, and only in groups (when we're not in a .private conversation).
|
||||||
.outgoing .quoted-message, .private .incoming .quoted-message {
|
.outgoing .quoted-message,
|
||||||
|
.private .incoming .quoted-message {
|
||||||
margin-top: $android-bubble-quote-padding - $android-bubble-padding-vertical;
|
margin-top: $android-bubble-quote-padding - $android-bubble-padding-vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottom-bar .quoted-message {
|
.bottom-bar .quoted-message {
|
||||||
margin: 0px;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to use the wrapper because the conversation view calculates the height of all
|
// We need to use the wrapper because the conversation view calculates the height of all
|
||||||
|
|
|
@ -231,7 +231,6 @@ describe('Backup', () => {
|
||||||
it('exports then imports to produce the same data we started with', async () => {
|
it('exports then imports to produce the same data we started with', async () => {
|
||||||
const {
|
const {
|
||||||
attachmentsPath,
|
attachmentsPath,
|
||||||
fs,
|
|
||||||
fse,
|
fse,
|
||||||
glob,
|
glob,
|
||||||
path,
|
path,
|
||||||
|
@ -266,14 +265,16 @@ describe('Backup', () => {
|
||||||
return _.omit(model, ['id']);
|
return _.omit(model, ['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want to know which paths have two slashes, since that tells us which files
|
||||||
|
// in the attachment fan-out are files vs. directories.
|
||||||
|
const TWO_SLASHES = /[^/]*\/[^/]*\/[^/]*/;
|
||||||
// On windows, attachmentsPath has a normal windows path format (\ separators), but
|
// On windows, attachmentsPath has a normal windows path format (\ separators), but
|
||||||
// glob returns only /. We normalize to / separators for our manipulations.
|
// glob returns only /. We normalize to / separators for our manipulations.
|
||||||
const twoSlashes = /[^/]*\/[^/]*\/[^/]*/;
|
|
||||||
const normalizedBase = attachmentsPath.replace(/\\/g, '/');
|
const normalizedBase = attachmentsPath.replace(/\\/g, '/');
|
||||||
function removeDirs(dirs) {
|
function removeDirs(dirs) {
|
||||||
return _.filter(dirs, (fullDir) => {
|
return _.filter(dirs, (fullDir) => {
|
||||||
const dir = fullDir.replace(normalizedBase, '');
|
const dir = fullDir.replace(normalizedBase, '');
|
||||||
return twoSlashes.test(dir);
|
return TWO_SLASHES.test(dir);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +434,7 @@ describe('Backup', () => {
|
||||||
|
|
||||||
console.log('Backup test: Ensure that messages.zip exists');
|
console.log('Backup test: Ensure that messages.zip exists');
|
||||||
const zipPath = path.join(backupDir, 'messages.zip');
|
const zipPath = path.join(backupDir, 'messages.zip');
|
||||||
const messageZipExists = fs.existsSync(zipPath);
|
const messageZipExists = fse.existsSync(zipPath);
|
||||||
assert.strictEqual(true, messageZipExists);
|
assert.strictEqual(true, messageZipExists);
|
||||||
|
|
||||||
console.log('Backup test: Ensure that all attachments made it to backup dir');
|
console.log('Backup test: Ensure that all attachments made it to backup dir');
|
||||||
|
|
|
@ -14,6 +14,11 @@ describe('NetworkStatusView', function() {
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
window.getSocketStatus = oldGetSocketStatus;
|
window.getSocketStatus = oldGetSocketStatus;
|
||||||
|
|
||||||
|
// It turns out that continued calls to window.getSocketStatus happen
|
||||||
|
// because we host NetworkStatusView in three mock interfaces, and the view
|
||||||
|
// checks every N seconds. That results in infinite errors unless there is
|
||||||
|
// something to call.
|
||||||
window.getSocketStatus = function() { return WebSocket.OPEN; };
|
window.getSocketStatus = function() { return WebSocket.OPEN; };
|
||||||
});
|
});
|
||||||
/* END stubbing globals */
|
/* END stubbing globals */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue