From 8bc32a3e771f430a946aada86a55764be6fc2e61 Mon Sep 17 00:00:00 2001 From: Saket Mahajan Date: Wed, 4 Nov 2020 22:55:06 +0530 Subject: [PATCH] [BUG] App isn't showing message for PDF/file uploads (#2584) * Fixed the issue #2531 In app/containers/message/Reply.js added a View Contaier around the Attachment Touchable and Added a Markdown attribute with msg set to description of attachment to display the message if any. * Added the condition to check if File Description Exists Added an if statement to check if file description exists and if yes then add a markdown with value msg equal to the description. Also tested using 'yarn test -u' to add/update the tests. * Made the requested Changes Removed the condition to check for attachment description. Added the `markdown` inside the touchable and wrapped `attachmentContainer` and the `markdown` inside a `<>` component * Added file not showing message issue code in this branch * Fixed the mistake in return * fix * Add tests Co-authored-by: Diego Mello --- .../__snapshots__/Storyshots.test.js.snap | 562 +++++++++++++++++- app/containers/message/Reply.js | 63 +- storybook/stories/Message.js | 31 +- 3 files changed, 623 insertions(+), 33 deletions(-) diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index ac8bb8e8a..7d0605ac7 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -27479,7 +27479,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { - "uri": "https://open.rocket.chat/file-upload/2ZrxuwcGeTrsoh376/Clipboard%252520-%252520September%2525205,%2525202018%2525204:10%252520PM?rc_uid=&rc_token=", + "uri": "https://open.rocket.chat/dummypath?rc_uid=&rc_token=", } } style={ @@ -27785,7 +27785,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { - "uri": "https://open.rocket.chat/file-upload/sxLXBzjwuqxMnebyP/Clipboard%252520-%25252029%252520de%252520Agosto%252520de%2525202018%252520%2525C3%2525A0s%25252018:10?rc_uid=&rc_token=", + "uri": "https://open.rocket.chat/dummypath?rc_uid=&rc_token=", } } style={ @@ -29517,6 +29517,564 @@ exports[`Storyshots Message list message 1`] = ` + + With file + + + + + + + + + + + + + + + + + diego.mello + + + + 10:00 AM + + + + + + + + File.pdf + + + + + + + This is a description + + + + + + + + + + + + + + + + + + + + + File.pdf + + + + + + + This is a description + + + + + + + + + + 0 && styles.marginTop, - { - backgroundColor: themes[theme].chatComponentBackground, - borderColor: themes[theme].borderColor - } - ]} - background={Touchable.Ripple(themes[theme].bannerBackground)} - > - - - <Description - attachment={attachment} - timeFormat={timeFormat} - getCustomEmoji={getCustomEmoji} - theme={theme} - /> - <Fields attachment={attachment} theme={theme} /> - </View> - </Touchable> + <> + <Touchable + onPress={onPress} + style={[ + styles.button, + index > 0 && styles.marginTop, + attachment.description && styles.marginBottom, + { + backgroundColor: themes[theme].chatComponentBackground, + borderColor: themes[theme].borderColor + } + ]} + background={Touchable.Ripple(themes[theme].bannerBackground)} + > + <View style={styles.attachmentContainer}> + <Title + attachment={attachment} + timeFormat={timeFormat} + theme={theme} + /> + <Description + attachment={attachment} + timeFormat={timeFormat} + getCustomEmoji={getCustomEmoji} + theme={theme} + /> + <Fields attachment={attachment} theme={theme} /> + </View> + </Touchable> + <Markdown + msg={attachment.description} + baseUrl={baseUrl} + username={user.username} + getCustomEmoji={getCustomEmoji} + theme={theme} + /> + </> ); }, (prevProps, nextProps) => isEqual(prevProps.attachment, nextProps.attachment) && prevProps.theme === nextProps.theme); diff --git a/storybook/stories/Message.js b/storybook/stories/Message.js index 1da166ffb..3068302cb 100644 --- a/storybook/stories/Message.js +++ b/storybook/stories/Message.js @@ -346,14 +346,14 @@ export default ({ theme }) => { attachments={[{ title: 'This is a title', description: 'This is a description', - image_url: '/file-upload/2ZrxuwcGeTrsoh376/Clipboard%20-%20September%205,%202018%204:10%20PM' + image_url: '/dummypath' }]} /> <Message attachments={[{ title: 'This is a title', description: 'This is a description :nyan_rocket:', - image_url: '/file-upload/sxLXBzjwuqxMnebyP/Clipboard%20-%2029%20de%20Agosto%20de%202018%20%C3%A0s%2018:10' + image_url: '/dummypath' }]} /> @@ -362,13 +362,13 @@ export default ({ theme }) => { attachments={[{ title: 'This is a title', description: 'This is a description :nyan_rocket:', - video_url: '/file-upload/cqnKqb6kdajky5Rxj/WhatsApp%20Video%202018-08-22%20at%2019.09.55.mp4' + video_url: '/dummypath' }]} /> <Message attachments={[{ title: 'This is a title', - video_url: '/file-upload/cqnKqb6kdajky5Rxj/WhatsApp%20Video%202018-08-22%20at%2019.09.55.mp4' + video_url: '/dummypath' }]} /> @@ -377,7 +377,7 @@ export default ({ theme }) => { attachments={[{ title: 'This is a title', description: 'This is a description :nyan_rocket:', - audio_url: '/file-upload/c4wcNhrbXJLBvAJtN/1535569819516.aac' + audio_url: '/dummypath' }]} /> <Message msg='First message' isHeader={false} /> @@ -385,21 +385,36 @@ export default ({ theme }) => { attachments={[{ title: 'This is a title', description: 'This is a description', - audio_url: '/file-upload/c4wcNhrbXJLBvAJtN/1535569819516.aac' + audio_url: '/dummypath' }]} isHeader={false} /> <Message attachments={[{ title: 'This is a title', - audio_url: '/file-upload/c4wcNhrbXJLBvAJtN/1535569819516.aac' + audio_url: '/dummypath' }]} isHeader={false} /> <Message attachments={[{ title: 'This is a title', - audio_url: '/file-upload/c4wcNhrbXJLBvAJtN/1535569819516.aac' + audio_url: '/dummypath' + }]} + isHeader={false} + /> + + <Separator title='With file' theme={theme} /> + <Message + attachments={[{ + text: 'File.pdf', + description: 'This is a description :nyan_rocket:' + }]} + /> + <Message + attachments={[{ + text: 'File.pdf', + description: 'This is a description :nyan_rocket:' }]} isHeader={false} />