A few bug fixes

This commit is contained in:
Scott Nonnenberg 2021-02-26 07:08:59 -08:00 committed by Josh Perez
parent 4b28fd896a
commit 2aa2aca9f2
6 changed files with 76 additions and 27 deletions

View file

@ -11542,9 +11542,6 @@ $contact-modal-padding: 18px;
// To limit messages with things forcing them wider, like long attachment names
.module-message__container {
// 2px to allow for 1px border
max-width: 302px;
&--incoming {
align-self: flex-start;
}
@ -11679,15 +11676,20 @@ $contact-modal-padding: 18px;
}
}
/* Spec: container < 437px */
@media (min-width: 0px) and (max-width: 799px) {
.module-message {
// Add 2px for 1px border
max-width: 302px;
}
}
/* Spec: container > 438px and container < 593px */
@media (min-width: 800px) and (max-width: 925px) {
.module-message {
// Add 2px for 1px border
max-width: 376px;
}
.module-message__container {
max-width: 100%;
}
// Spec: container < 438px
.module-message--incoming {
@ -11722,9 +11724,6 @@ $contact-modal-padding: 18px;
.module-message {
max-width: 66%;
}
.module-message__container {
max-width: 100%;
}
.module-message--incoming {
margin-right: auto;

View file

@ -626,7 +626,17 @@ type WhatIsThis = import('./window.d').WhatIsThis;
Views.Initialization.setMessage(window.i18n('optimizingApplication'));
if (newVersion) {
await window.Signal.Data.cleanupOrphanedAttachments();
// We've received reports that this update can take longer than two minutes, so we
// allow it to continue and just move on in that timeout case.
try {
await window.Signal.Data.cleanupOrphanedAttachments();
} catch (error) {
window.log.error(
'background: Failed to cleanup orphaned attachments:',
error && error.stack ? error.stack : error
);
}
// Don't block on the following operation
window.Signal.Data.ensureFilePermissions();
}

View file

@ -755,6 +755,23 @@ story.add('Other File Type with Caption', () => {
return renderBothDirections(props);
});
story.add('Other File Type with Long Filename', () => {
const props = createProps({
attachments: [
{
contentType: 'text/plain' as MIMEType,
fileName:
'INSERT-APP-NAME_INSERT-APP-APPLE-ID_AppStore_AppsGamesWatch.psd.zip',
url: 'a2/a2334324darewer4234',
},
],
status: 'sent',
text: 'This is what I have done.',
});
return renderBothDirections(props);
});
story.add('TapToView Image', () => {
const props = createProps({
attachments: [

View file

@ -2803,11 +2803,7 @@ export class ConversationModel extends window.Backbone.Model<
return Promise.all(
attachments
.filter(
attachment =>
attachment &&
attachment.contentType &&
!attachment.pending &&
!attachment.error
attachment => attachment && !attachment.pending && !attachment.error
)
.slice(0, 1)
.map(async attachment => {

View file

@ -424,7 +424,7 @@ export const getConversationSelector = createSelector(
if (onE164) {
return selector(onE164);
}
const onUuid = getOwn(byUuid, id);
const onUuid = getOwn(byUuid, id.toLowerCase ? id.toLowerCase() : id);
if (onUuid) {
return selector(onUuid);
}

View file

@ -1372,8 +1372,15 @@ Whisper.ConversationView = Whisper.View.extend({
const { files } = e.originalEvent.dataTransfer;
for (let i = 0, max = files.length; i < max; i += 1) {
const file = files[i];
// eslint-disable-next-line no-await-in-loop
await this.maybeAddAttachment(file);
try {
// eslint-disable-next-line no-await-in-loop
await this.maybeAddAttachment(file);
} catch (error) {
window.log.error(
'ConversationView/onDrop: Failed to add attachment:',
error && error.stack ? error.stack : error
);
}
}
},
@ -1399,12 +1406,23 @@ Whisper.ConversationView = Whisper.View.extend({
return {
// In conversation model/redux
attachments: draftAttachments.map((attachment: any) => ({
...attachment,
url: attachment.screenshotPath
? getAbsoluteDraftPath(attachment.screenshotPath)
: getAbsoluteDraftPath(attachment.path),
})),
attachments: draftAttachments.map((attachment: any) => {
let url = '';
if (attachment.screenshotPath) {
url = getAbsoluteDraftPath(attachment.screenshotPath);
} else if (attachment.path) {
url = getAbsoluteDraftPath(attachment.path);
} else {
window.log.warn(
'getPropsForAttachmentList: Attachment was missing both screenshotPath and path fields'
);
}
return {
...attachment,
url,
};
}),
// Passed in from ConversationView
onAddAttachment: this.onChooseAttachment.bind(this),
onClickAttachment: this.onClickAttachment.bind(this),
@ -1479,9 +1497,9 @@ Whisper.ConversationView = Whisper.View.extend({
draftAttachments: [...draftAttachments, onDisk],
draftChanged: true,
});
await this.saveModel();
this.updateAttachmentsView();
await this.saveModel();
},
async onCloseAttachment(attachment: any) {
@ -1701,7 +1719,16 @@ Whisper.ConversationView = Whisper.View.extend({
return;
}
await this.addAttachment(attachment);
try {
await this.addAttachment(attachment);
} catch (error) {
window.log.error(
'Error saving draft attachment:',
error && error.stack ? error.stack : error
);
this.showToast(Whisper.UnableToLoadToast);
}
},
isSizeOkay(attachment: any) {