From 0d528bd9ae665891ceed92803be5b0d2046f916c Mon Sep 17 00:00:00 2001 From: Sumukha Hegde Date: Fri, 27 Aug 2021 19:37:16 +0530 Subject: [PATCH] [FIX] Show thumbnails in message view (#2975) * [FIX] Show thumbnails in message view fixes: #2853 * Add stories for thumbnails and update test * [Test] Update tests * added stories Co-authored-by: Reinaldo Neto Co-authored-by: Levy Costa Co-authored-by: Diego Mello --- .../__snapshots__/Storyshots.test.js.snap | 446 ++++++++++++++++++ app/containers/message/Reply.js | 33 +- storybook/stories/Message.js | 13 + 3 files changed, 489 insertions(+), 3 deletions(-) diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 84457cec0..6f0df6b98 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -20361,6 +20361,15 @@ exports[`Storyshots Message Colored attachments 1`] = ` } } > + + + `; +exports[`Storyshots Message Thumbnail from server 1`] = ` + + + + + + + + + + + + + + + + + + diego.mello + + + + 10:00 AM + + + + + + this is a thumbnail + + + + + + + + Joker + + + + + + + + Some crazy texts + + + + + + + + + + + +`; + exports[`Storyshots Message Time format 1`] = ` + + { - if (!attachment.author_name) { - return null; - } const time = attachment.message_link && attachment.ts ? moment(attachment.ts).format(timeFormat) : null; return ( {attachment.author_name ? {attachment.author_name} : null} + {attachment.title ? {attachment.title} : null} {time ? { time } : null} ); @@ -112,6 +125,15 @@ const Description = React.memo(({ return true; }); +const UrlImage = React.memo(({ image }) => { + if (!image) { + return null; + } + const { baseUrl, user } = useContext(MessageContext); + image = image.includes('http') ? image : `${ baseUrl }/${ image }?rc_uid=${ user.id }&rc_token=${ user.token }`; + return ; +}, (prevProps, nextProps) => prevProps.image === nextProps.image); + const Fields = React.memo(({ attachment, theme, getCustomEmoji }) => { if (!attachment.fields) { return null; @@ -191,6 +213,7 @@ const Reply = React.memo(({ timeFormat={timeFormat} theme={theme} /> + ( stories.add('Custom style', () => ( )); + +stories.add('Thumbnail from server', () => ( + +)); +