diff --git a/js/models/messages.d.ts b/js/models/messages.d.ts index 2a5ef4a98..7bd1ed2eb 100644 --- a/js/models/messages.d.ts +++ b/js/models/messages.d.ts @@ -39,7 +39,6 @@ interface MessageAttributes { expirationTimerUpdate: any; unread: boolean; group: any; - bodyPending: boolean; timestamp: number; status: MessageDeliveryStatus; } @@ -50,7 +49,6 @@ export interface MessageRegularProps { isAdmin?: boolean; weAreAdmin?: boolean; text?: string; - bodyPending?: boolean; id: string; collapseMetadata?: boolean; direction: 'incoming' | 'outgoing'; diff --git a/js/models/messages.js b/js/models/messages.js index c209a0df1..817fc69b6 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -29,7 +29,6 @@ loadQuoteData, loadPreviewData, } = window.Signal.Migrations; - const { bytesFromString } = window.Signal.Crypto; window.AccountCache = Object.create(null); window.AccountJobs = Object.create(null); @@ -525,7 +524,6 @@ return { text: this.createNonBreakingLastSeparator(this.get('body')), - bodyPending: this.get('bodyPending'), id: this.id, direction: this.isIncoming() ? 'incoming' : 'outgoing', timestamp: this.get('sent_at'), @@ -870,17 +868,10 @@ // TODO: In the future it might be best if we cache the upload results if possible. // This way we don't upload duplicated data. - const attachmentsWithData = await Promise.all( + const finalAttachments = await Promise.all( (this.get('attachments') || []).map(loadAttachmentData) ); - const { - body, - attachments: finalAttachments, - } = Whisper.Message.getLongMessageAttachment({ - body: this.get('body'), - attachments: attachmentsWithData, - now: this.get('sent_at'), - }); + const filenameOverridenAttachments = finalAttachments.map(attachment => ({ ...attachment, fileName: Signal.Types.Attachment.getSuggestedFilenameSending({ @@ -906,7 +897,7 @@ ]); return { - body, + body: this.get('body'), attachments, preview, quote, @@ -1531,31 +1522,6 @@ }, }); - // Receive will be enabled before we enable send - Whisper.Message.LONG_MESSAGE_CONTENT_TYPE = 'text/x-signal-plain'; - - Whisper.Message.getLongMessageAttachment = ({ body, attachments, now }) => { - if (body.length <= 2048) { - return { - body, - attachments, - }; - } - - const data = bytesFromString(body); - const attachment = { - contentType: Whisper.Message.LONG_MESSAGE_CONTENT_TYPE, - fileName: `long-message-${now}.txt`, - data, - size: data.byteLength, - }; - - return { - body: body.slice(0, 2048), - attachments: [attachment, ...attachments], - }; - }; - Whisper.Message.refreshExpirationTimer = () => Whisper.ExpiringMessagesListener.update(); diff --git a/js/modules/attachment_downloads.js b/js/modules/attachment_downloads.js index 38b30a84a..9468b6f78 100644 --- a/js/modules/attachment_downloads.js +++ b/js/modules/attachment_downloads.js @@ -263,7 +263,6 @@ async function _addAttachmentToMessage(message, attachment, { type, index }) { const { data } = await Signal.Migrations.loadAttachmentData(attachment); message.set({ body: attachment.isError ? message.get('body') : stringFromBytes(data), - bodyPending: false, }); } finally { Signal.Migrations.deleteAttachmentData(attachment.path); diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 55a6e77ca..28b9c0f48 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -547,7 +547,6 @@ class MessageInner extends React.PureComponent { public renderText() { const { text, - bodyPending, direction, status, conversationType, @@ -578,7 +577,6 @@ class MessageInner extends React.PureComponent { ` tags. */ @@ -83,26 +82,13 @@ export class MessageBody extends React.Component { isGroup: false, }; - public addDownloading(jsx: JSX.Element): JSX.Element { - const { i18n, bodyPending } = this.props; - - return ( - - {jsx} - {bodyPending ? ( - - {' '} - {i18n('downloading')} - - ) : null} - - ); + public renderJsxSelectable(jsx: JSX.Element): JSX.Element { + return {jsx}; } public render() { const { text, - bodyPending, disableJumbomoji, disableLinks, i18n, @@ -110,23 +96,12 @@ export class MessageBody extends React.Component { convoId, } = this.props; const sizeClass = disableJumbomoji ? undefined : getSizeClass(text); - const textWithPending = bodyPending ? `${text}...` : text; - - const emoji = renderEmoji({ - i18n, - text: textWithPending, - sizeClass, - key: 0, - renderNonEmoji: renderNewLines, - isGroup, - convoId, - }); if (disableLinks) { - return this.addDownloading( + return this.renderJsxSelectable( renderEmoji({ i18n, - text: textWithPending, + text, sizeClass, key: 0, renderNonEmoji: renderNewLines, @@ -136,26 +111,9 @@ export class MessageBody extends React.Component { ); } - const bodyContents = this.addDownloading( + return this.renderJsxSelectable( { - return renderEmoji({ - i18n, - text: nonLinkText, - sizeClass, - key, - renderNonEmoji: renderNewLines, - isGroup, - convoId, - }); - }} - /> - ); - - return this.addDownloading( - { return renderEmoji({ i18n, diff --git a/ts/components/conversation/message/MessageMetadata.tsx b/ts/components/conversation/message/MessageMetadata.tsx index dec4ce8fb..f11b87b06 100644 --- a/ts/components/conversation/message/MessageMetadata.tsx +++ b/ts/components/conversation/message/MessageMetadata.tsx @@ -17,7 +17,6 @@ type Props = { isAdmin?: boolean; isDeletable: boolean; text?: string; - bodyPending?: boolean; id: string; collapseMetadata?: boolean; direction: 'incoming' | 'outgoing'; @@ -69,7 +68,6 @@ export const MessageMetadata = (props: Props) => { expirationTimestamp, status, text, - bodyPending, timestamp, serverTimestamp, isShowingImage, @@ -86,7 +84,7 @@ export const MessageMetadata = (props: Props) => { const withImageNoCaption = Boolean(!text && isShowingImage); const showError = status === 'error' && isOutgoing; - const showStatus = Boolean(!bodyPending && status?.length && isOutgoing); + const showStatus = Boolean(status?.length && isOutgoing); const messageStatusColor = withImageNoCaption ? 'white' : props.theme.colors.sentMessageText; @@ -124,8 +122,6 @@ export const MessageMetadata = (props: Props) => { /> ) : null} - {bodyPending ? : null} - {showStatus ? ( { spellCheck={true} inputRef={this.textarea} disabled={!typingEnabled} - maxLength={Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH} + // maxLength={Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH} rows={1} style={sendMessageStyle} suggestionsPortalHost={this.container} @@ -751,25 +751,8 @@ export class SessionCompositionBox extends React.Component { // tslint:disable-next-line: cyclomatic-complexity private async onSendMessage() { - const toUnicode = (str: string) => { - return str - .split('') - .map(value => { - const temp = value - .charCodeAt(0) - .toString(16) - .toUpperCase(); - if (temp.length > 2) { - return `\\u${temp}`; - } - return value; - }) - .join(''); - }; - // this is dirty but we have to replace all @(xxx) by @xxx manually here const cleanMentions = (text: string): string => { - const textUnicode = toUnicode(text); const matches = text.match(this.mentionsRegex); let replacedMentions = text; (matches || []).forEach(match => { @@ -808,10 +791,10 @@ export class SessionCompositionBox extends React.Component { } // Verify message length const msgLen = messagePlaintext?.length || 0; - if (msgLen > Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH) { - ToastUtils.pushMessageBodyTooLong(); - return; - } + // if (msgLen > Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH) { + // ToastUtils.pushMessageBodyTooLong(); + // return; + // } if (msgLen === 0 && this.props.stagedAttachments?.length === 0) { ToastUtils.pushMessageBodyMissing(); return; diff --git a/ts/receiver/attachments.ts b/ts/receiver/attachments.ts index a577680da..91616c963 100644 --- a/ts/receiver/attachments.ts +++ b/ts/receiver/attachments.ts @@ -75,32 +75,6 @@ export async function downloadAttachment(attachment: any) { }; } -async function processLongAttachments( - message: MessageModel, - attachments: Array -): Promise { - if (attachments.length === 0) { - return false; - } - - if (attachments.length > 1) { - window.log.error( - `Received more than one long message attachment in message ${message.idForLogging()}` - ); - } - - const attachment = attachments[0]; - - message.set({ bodyPending: true }); - await window.Signal.AttachmentDownloads.addJob(attachment, { - messageId: message.id, - type: 'long-message', - index: 0, - }); - - return true; -} - async function processNormalAttachments( message: MessageModel, normalAttachments: Array @@ -247,15 +221,7 @@ export async function queueAttachmentDownloads( let count = 0; - const [longMessageAttachments, normalAttachments] = _.partition( - message.get('attachments') || [], - (attachment: any) => - attachment.contentType === Whisper.Message.LONG_MESSAGE_CONTENT_TYPE - ); - - if (await processLongAttachments(message, longMessageAttachments)) { - count += 1; - } + const normalAttachments = message.get('attachments') || []; count += await processNormalAttachments(message, normalAttachments); diff --git a/ts/session/constants.ts b/ts/session/constants.ts index e8475c9e8..65ca1f7cc 100644 --- a/ts/session/constants.ts +++ b/ts/session/constants.ts @@ -11,7 +11,7 @@ export const TTL_DEFAULT = { // User Interface export const CONVERSATION = { - MAX_MESSAGE_BODY_LENGTH: 2000, + // MAX_MESSAGE_BODY_LENGTH: 2000, DEFAULT_MEDIA_FETCH_COUNT: 50, DEFAULT_DOCUMENTS_FETCH_COUNT: 150, DEFAULT_MESSAGE_FETCH_COUNT: 30,