From ff4bf0c5f03874a05e07f01f410757aba6dc64b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Tkaczy=C5=84ski?= Date: Fri, 13 Oct 2017 21:48:50 +0200 Subject: [PATCH] Render embed for short posts with embed --- src/components/Story/StoryHelper.js | 1 + src/components/Story/StoryPreview.js | 21 +++++++++++-------- .../__snapshots__/stories.test.js.snap | 16 +++++++------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/components/Story/StoryHelper.js b/src/components/Story/StoryHelper.js index 23f7d1e7cf..e6d77c86b5 100644 --- a/src/components/Story/StoryHelper.js +++ b/src/components/Story/StoryHelper.js @@ -32,6 +32,7 @@ const isPostWithEmbedBeforeFirstHalf = tagPositions => postWithAnEmbed(tagPositi export { getPositions, + postWithAnEmbed, isPostStartsWithAPicture, isPostStartsWithAnEmbed, isPostWithPictureBeforeFirstHalf, diff --git a/src/components/Story/StoryPreview.js b/src/components/Story/StoryPreview.js index 9ce846e624..5422b5e6c7 100644 --- a/src/components/Story/StoryPreview.js +++ b/src/components/Story/StoryPreview.js @@ -8,6 +8,7 @@ import { jsonParse } from '../../helpers/formatter'; import { image } from '../../vendor/steemitLinks'; import { getPositions, + postWithAnEmbed, isPostStartsWithAPicture, isPostStartsWithAnEmbed, isPostWithPictureBeforeFirstHalf, @@ -37,7 +38,9 @@ const StoryPreview = ({ post }) => { embeds[0] = { type: 'video', provider_name: 'DTube', - embed: ``, + embed: ``, thumbnail: getProxyImageURL(`https://ipfs.io/ipfs/${video.info.snaphash}`, 'preview'), }; } @@ -47,10 +50,11 @@ const StoryPreview = ({ post }) => { embed: () => embeds && embeds[0] && , - image: () => - (
+ image: () => ( +
post -
), +
+ ), }; const htmlBody = getHtml(post.body, {}, 'text'); @@ -60,6 +64,9 @@ const StoryPreview = ({ post }) => { if (hasVideo) { bodyData.push(preview.embed()); bodyData.push(preview.text()); + } else if (htmlBody.length <= 1500 && postWithAnEmbed(tagPositions, 100)) { + bodyData.push(preview.embed()); + bodyData.push(preview.text()); } else if (isPostStartsWithAPicture(tagPositions)) { bodyData.push(preview.image()); bodyData.push(preview.text()); @@ -76,11 +83,7 @@ const StoryPreview = ({ post }) => { bodyData.push(preview.text()); } - return ( -
- {bodyData} -
- ); + return
{bodyData}
; }; StoryPreview.propTypes = { diff --git a/src/stories/__snapshots__/stories.test.js.snap b/src/stories/__snapshots__/stories.test.js.snap index 1bedb1499f..8c28b53a0b 100644 --- a/src/stories/__snapshots__/stories.test.js.snap +++ b/src/stories/__snapshots__/stories.test.js.snap @@ -2651,14 +2651,6 @@ exports[`Storyshots Story Inline story with embed 1`] = ` onClick={[Function]} >
-
+