Skip to content

Commit

Permalink
fix: ASC-26704 - story duplicate (#700)
Browse files Browse the repository at this point in the history
* fix: button type

* fix: remove duplicate story
  • Loading branch information
ChayanitBm authored Oct 25, 2024
1 parent 74dcd13 commit 55dd372
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/v4/social/elements/ShareStoryButton/ShareStoryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<SVGSVGElement>) => {
return (
Expand Down Expand Up @@ -47,11 +48,10 @@ export const ShareStoryButton = ({
if (isExcluded) return null;

return (
<button
role="button"
<Button
className={clsx(styles.shareStoryButton)}
data-qa-anchor={accessibilityId}
onClick={onClick}
onPress={onClick}
data-hideAvatar={config?.hide_avatar}
>
{!config?.hide_avatar && (
Expand All @@ -64,6 +64,6 @@ export const ShareStoryButton = ({
)}
<Typography.BodyBold>{config?.text || 'Share story'}</Typography.BodyBold>
<ArrowRightIcon />
</button>
</Button>
);
};
18 changes: 17 additions & 1 deletion src/v4/social/pages/StoryPage/CommunityFeedStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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 }) => {
Expand Down

0 comments on commit 55dd372

Please sign in to comment.