File size: 1,692 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
// @flow
import React, { useState } from 'react';
import compose from 'recompose/compose';
import type { GetCommunityType } from 'shared/graphql/queries/community/getCommunity';
import type { UserInfoType } from 'shared/graphql/fragments/user/userInfo';
import getCommunityThreads from 'shared/graphql/queries/community/getCommunityThreadConnection';
import ThreadFeed from 'src/components/threadFeed';
import Select from 'src/components/select';
import { withCurrentUser } from 'src/components/withCurrentUser';
import { PostsFeedsSelectorContainer } from '../style';
const CommunityThreadFeed = compose(getCommunityThreads)(ThreadFeed);
type Props = {
community: GetCommunityType,
currentUser: ?UserInfoType,
};
export const PostsFeeds = withCurrentUser((props: Props) => {
const { community, currentUser } = props;
const defaultFeed = !currentUser ? 'trending' : 'latest';
const [activeFeed, setActiveFeed] = useState(defaultFeed);
return (
<React.Fragment>
<PostsFeedsSelectorContainer>
<Select
value={activeFeed}
onChange={e => setActiveFeed(e.target.value)}
>
<option key="latest" value="latest">
Latest
</option>
<option key="trending" value="trending">
Popular
</option>
</Select>
</PostsFeedsSelectorContainer>
<CommunityThreadFeed
viewContext="communityProfile"
slug={community.slug}
id={community.id}
setThreadsStatus={false}
isNewAndOwned={false}
community={community}
pinnedThreadId={community.pinnedThreadId}
sort={activeFeed}
/>
</React.Fragment>
);
});
|