From 55dd3729e4a44c0b8f63267dfb12a1e794476e62 Mon Sep 17 00:00:00 2001 From: ChayanitBm Date: Fri, 25 Oct 2024 13:13:29 +0700 Subject: [PATCH] fix: ASC-26704 - story duplicate (#700) * fix: button type * fix: remove duplicate story --- .../ShareStoryButton/ShareStoryButton.tsx | 8 ++++---- .../pages/StoryPage/CommunityFeedStory.tsx | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/v4/social/elements/ShareStoryButton/ShareStoryButton.tsx b/src/v4/social/elements/ShareStoryButton/ShareStoryButton.tsx index 8a43ff4c..9feb99ec 100644 --- a/src/v4/social/elements/ShareStoryButton/ShareStoryButton.tsx +++ b/src/v4/social/elements/ShareStoryButton/ShareStoryButton.tsx @@ -5,6 +5,7 @@ import { useAmityElement } from '~/v4/core/hooks/uikit'; import styles from './ShareStoryButton.module.css'; import { CommunityAvatar } from '~/v4/social/elements/CommunityAvatar'; +import { Button } from '~/v4/core/natives/Button'; const ArrowRightIcon = (props: React.SVGProps) => { return ( @@ -47,11 +48,10 @@ export const ShareStoryButton = ({ if (isExcluded) return null; return ( - + ); }; diff --git a/src/v4/social/pages/StoryPage/CommunityFeedStory.tsx b/src/v4/social/pages/StoryPage/CommunityFeedStory.tsx index 52b393f9..25dd39f9 100644 --- a/src/v4/social/pages/StoryPage/CommunityFeedStory.tsx +++ b/src/v4/social/pages/StoryPage/CommunityFeedStory.tsx @@ -70,7 +70,7 @@ export const CommunityFeedStory = ({ const dragEventTarget = useRef(new EventTarget()); const [isBottomSheetOpen, setIsBottomSheetOpen] = useState(false); - const { stories } = useGetActiveStoriesByTarget({ + const { stories: storiesData } = useGetActiveStoriesByTarget({ targetId: communityId, targetType: 'community', options: { @@ -79,6 +79,22 @@ export const CommunityFeedStory = ({ }, }); + const stories = storiesData.reduce( + (acc: (Amity.Ad | Amity.Story)[], current: Amity.Ad | Amity.Story) => { + const isDuplicate = acc.find((item) => { + if (isStory(item) && isStory(current)) { + return item.storyId === current.storyId; + } + return false; + }); + if (!isDuplicate) { + acc.push(current); + } + return acc; + }, + [], + ); + const communityFeedRenderers = useMemo( () => renderers.map(({ renderer, tester }) => {