Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ignore comments on feed #4513

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions apps/web/src/components/Home/FeedEventFilters.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions apps/web/src/components/Home/FeedType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import isFeatureEnabled from '@lib/isFeatureEnabled';
import { Leafwatch } from '@lib/leafwatch';

import Algorithms from './Algorithms';
import FeedEventFilters from './FeedEventFilters';
import SeeThroughLens from './SeeThroughLens';

interface FeedTypeProps {
Expand Down Expand Up @@ -61,7 +60,6 @@ const FeedType: FC<FeedTypeProps> = ({ feedType, setFeedType }) => {
feedType === HomeFeedType.HIGHLIGHTS ? (
<SeeThroughLens />
) : null}
{feedType === HomeFeedType.FOLLOWING ? <FeedEventFilters /> : null}
{IS_MAINNET ? <Algorithms /> : null}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ interface CombinedProps {
}

const Combined: FC<CombinedProps> = ({ feedItem }) => {
const { acted, comments, mirrors, reactions } = feedItem;
const { acted, mirrors, reactions } = feedItem;

const mirrorsLength = mirrors.length;
const actedLength = acted.length;
const reactionsLength = reactions.length;
const commentsLength = comments?.length || 0;

const getAllProfiles = () => {
let profiles = [...mirrors, ...acted, ...reactions, ...comments].map(
let profiles = [...mirrors, ...acted, ...reactions].map(
(event) => event.by
);
profiles = profiles.filter(
Expand All @@ -31,9 +30,6 @@ const Combined: FC<CombinedProps> = ({ feedItem }) => {
if (mirrorsLength) {
actionArray.push('mirrored');
}
if (commentsLength) {
actionArray.push('commented');
}
if (actedLength) {
actionArray.push('acted');
}
Expand Down
24 changes: 0 additions & 24 deletions apps/web/src/components/Home/Timeline/EventType/Commented.tsx

This file was deleted.

19 changes: 5 additions & 14 deletions apps/web/src/components/Home/Timeline/EventType/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import stopEventPropagation from '@hey/lib/stopEventPropagation';

import Acted from './Acted';
import Combined from './Combined';
import Commented from './Commented';
import Liked from './Liked';
import Mirrored from './Mirrored';

Expand All @@ -19,15 +18,12 @@ interface ActionTypeProps {
}

const ActionType: FC<ActionTypeProps> = ({ feedItem }) => {
const { acted, comments, mirrors, reactions, root } = feedItem;
const isComment = root.__typename === 'Comment';
const showThread = isComment || (comments?.length || 0) > 0;
const { acted, mirrors, reactions } = feedItem;

const canCombined = getCanCombined([
mirrors?.length || 0,
reactions?.length || 0,
acted?.length || 0,
comments?.length || 0
acted?.length || 0
]);

return (
Expand All @@ -36,16 +32,11 @@ const ActionType: FC<ActionTypeProps> = ({ feedItem }) => {
<Combined feedItem={feedItem} />
) : (
<>
{mirrors?.length && !isComment ? (
<Mirrored mirrors={mirrors} />
) : null}
{acted?.length && !isComment ? <Acted acted={acted} /> : null}
{reactions?.length && !isComment ? (
<Liked reactions={reactions} />
) : null}
{mirrors?.length ? <Mirrored mirrors={mirrors} /> : null}
{acted?.length ? <Acted acted={acted} /> : null}
{reactions?.length ? <Liked reactions={reactions} /> : null}
</>
)}
{showThread ? <Commented feedItem={feedItem} /> : null}
</span>
);
};
Expand Down
42 changes: 10 additions & 32 deletions apps/web/src/components/Home/Timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,29 @@ import { useInView } from 'react-cool-inview';
import { useImpressionsStore } from 'src/store/non-persisted/useImpressionsStore';
import { useTimelineStore } from 'src/store/non-persisted/useTimelineStore';
import useProfileStore from 'src/store/persisted/useProfileStore';
import { useTimelineFilterStore } from 'src/store/persisted/useTimelineFilterStore';
import { useTransactionStore } from 'src/store/persisted/useTransactionStore';

const Timeline: FC = () => {
const currentProfile = useProfileStore((state) => state.currentProfile);
const txnQueue = useTransactionStore((state) => state.txnQueue);
const feedEventFilters = useTimelineFilterStore(
(state) => state.feedEventFilters
);
const seeThroughProfile = useTimelineStore(
(state) => state.seeThroughProfile
);
const fetchAndStoreViews = useImpressionsStore(
(state) => state.fetchAndStoreViews
);

const getFeedEventItems = () => {
const filters: FeedEventItemType[] = [];
if (feedEventFilters.posts) {
filters.push(FeedEventItemType.Post, FeedEventItemType.Comment);
}
if (feedEventFilters.collects) {
filters.push(FeedEventItemType.Collect, FeedEventItemType.Comment);
}
if (feedEventFilters.mirrors) {
filters.push(FeedEventItemType.Mirror);
}
if (feedEventFilters.likes) {
filters.push(FeedEventItemType.Reaction, FeedEventItemType.Comment);
}
return filters;
};

// Variables
const request: FeedRequest = {
where: {
feedEventItemTypes: getFeedEventItems(),
feedEventItemTypes: [
FeedEventItemType.Acted,
FeedEventItemType.Collect,
FeedEventItemType.Mirror,
FeedEventItemType.Post,
FeedEventItemType.Quote,
FeedEventItemType.Reaction
],
for: seeThroughProfile?.id || currentProfile?.id
}
};
Expand All @@ -58,11 +44,7 @@ const Timeline: FC = () => {
onCompleted: async ({ feed }) => {
const ids =
feed?.items?.flatMap((p) => {
return [
p.root.id,
p.comments?.[0]?.id,
p.root.__typename === 'Comment' && p.root.commentOn?.id
].filter((id) => id);
return [p.root.id].filter((id) => id);
}) || [];
await fetchAndStoreViews(ids);
},
Expand All @@ -84,11 +66,7 @@ const Timeline: FC = () => {
});
const ids =
data.feed?.items?.flatMap((p) => {
return [
p.root.id,
p.comments?.[0]?.id,
p.root.__typename === 'Comment' && p.root.commentOn?.id
].filter((id) => id);
return [p.root.id].filter((id) => id);
}) || [];
await fetchAndStoreViews(ids);
}
Expand Down
7 changes: 1 addition & 6 deletions apps/web/src/components/Publication/PublicationHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ const PublicationHeader: FC<PublicationHeaderProps> = ({
const targetPublication = isMirrorPublication(publication)
? publication?.mirrorOn
: publication;
const firstComment = feedItem?.comments?.[0];
const rootPublication = feedItem
? firstComment
? firstComment
: feedItem?.root
: targetPublication;
const rootPublication = feedItem ? feedItem?.root : targetPublication;
const profile = feedItem ? rootPublication.by : targetPublication.by;
const timestamp = feedItem
? rootPublication.createdAt
Expand Down
7 changes: 1 addition & 6 deletions apps/web/src/components/Publication/SinglePublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ const SinglePublication: FC<SinglePublicationProps> = ({
showThread = true,
showType = true
}) => {
const firstComment = feedItem?.comments?.[0];
const rootPublication = feedItem
? firstComment
? firstComment
: feedItem?.root
: publication;
const rootPublication = feedItem ? feedItem?.root : publication;
const { metadata } = isMirrorPublication(publication)
? publication.mirrorOn
: publication;
Expand Down
24 changes: 0 additions & 24 deletions apps/web/src/store/persisted/useTimelineFilterStore.ts

This file was deleted.

5 changes: 1 addition & 4 deletions packages/lens/documents/queries/Feed.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ query Feed($request: FeedRequest!) {
...PostFields
}
... on Comment {
...CommentFields
id
}
... on Quote {
...QuoteFields
Expand All @@ -28,9 +28,6 @@ query Feed($request: FeedRequest!) {
...PublicationProfileFields
}
}
comments {
...CommentBaseFields
}
}
pageInfo {
next
Expand Down
Loading
Loading