diff --git a/stylesheets/_modules.scss b/stylesheets/_modules.scss index f5a3525a0..cff75a61b 100644 --- a/stylesheets/_modules.scss +++ b/stylesheets/_modules.scss @@ -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; diff --git a/ts/background.ts b/ts/background.ts index 2c6b22cca..c02714d3a 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -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(); } diff --git a/ts/components/conversation/Message.stories.tsx b/ts/components/conversation/Message.stories.tsx index c9afc3b52..39e838b6d 100644 --- a/ts/components/conversation/Message.stories.tsx +++ b/ts/components/conversation/Message.stories.tsx @@ -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: [ diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index c896e055e..bffc43a8f 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -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 => { diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index f00bdb996..df6971687 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -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); } diff --git a/ts/views/conversation_view.ts b/ts/views/conversation_view.ts index b7466568c..df8836300 100644 --- a/ts/views/conversation_view.ts +++ b/ts/views/conversation_view.ts @@ -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) {