From 2755f09f59da70bcfdaf3554c583fc17d53ddc33 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Thu, 24 Aug 2023 22:22:52 +0300 Subject: [PATCH] repost merge improvement --- src/js/components/events/note/Note.tsx | 2 +- src/js/components/feed/Feed.tsx | 5 ++++- src/js/components/feed/types.ts | 1 + src/js/views/feeds/Global.tsx | 2 ++ src/js/views/feeds/Home.tsx | 2 ++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js/components/events/note/Note.tsx b/src/js/components/events/note/Note.tsx index 0982552cc..6deb3bf77 100644 --- a/src/js/components/events/note/Note.tsx +++ b/src/js/components/events/note/Note.tsx @@ -5,7 +5,7 @@ import { Link, route } from 'preact-router'; import InfiniteScroll from '@/components/helpers/InfiniteScroll'; import useSubscribe from '@/nostr/hooks/useSubscribe.ts'; -import { getNoteReplyingTo, getEventRoot } from '@/nostr/utils'; +import { getEventRoot, getNoteReplyingTo } from '@/nostr/utils'; import Key from '../../../nostr/Key'; import { translate as t } from '../../../translations/Translation.mjs'; diff --git a/src/js/components/feed/Feed.tsx b/src/js/components/feed/Feed.tsx index 8a51e0a52..820d148b4 100644 --- a/src/js/components/feed/Feed.tsx +++ b/src/js/components/feed/Feed.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useRef, useState } from 'react'; +import { useMemo } from 'preact/hooks'; import EventComponent from '@/components/events/EventComponent'; import DisplaySelector from '@/components/feed/DisplaySelector'; @@ -16,7 +17,6 @@ import useLocalState from '@/state/useLocalState.ts'; import Helpers from '@/utils/Helpers'; import { translate as t } from '../../translations/Translation.mjs'; -import {useMemo} from "preact/hooks"; const Feed = (props: FeedProps) => { const fetchEvents = props.fetchEvents || useSubscribe; @@ -62,6 +62,9 @@ const Feed = (props: FeedProps) => { const hiddenEvents = useMemo(() => { const hiddenEvents = new Set(); + if (!filterOption.mergeReposts) { + return hiddenEvents; + } const seenReposts = new Set(); for (const event of events) { if (isRepost(event)) { diff --git a/src/js/components/feed/types.ts b/src/js/components/feed/types.ts index 5fefe23e1..ec309dea2 100644 --- a/src/js/components/feed/types.ts +++ b/src/js/components/feed/types.ts @@ -26,4 +26,5 @@ export type FilterOption = { filter: Filter; filterFn?: (event: Event) => boolean; eventProps?: Partial; + mergeReposts?: boolean; }; diff --git a/src/js/views/feeds/Global.tsx b/src/js/views/feeds/Global.tsx index 36e6d547a..fe6b619d3 100644 --- a/src/js/views/feeds/Global.tsx +++ b/src/js/views/feeds/Global.tsx @@ -16,11 +16,13 @@ const Global: React.FC = () => { filter: { kinds: [1, 6], limit: 10 }, filterFn: (event) => !getEventReplyingTo(event) || isRepost(event), eventProps: { showRepliedMsg: true }, + mergeReposts: true, }, { name: t('posts_and_replies'), filter: { kinds: [1, 6], limit: 5 }, eventProps: { showRepliedMsg: true, fullWidth: false }, + mergeReposts: true, }, ], [], diff --git a/src/js/views/feeds/Home.tsx b/src/js/views/feeds/Home.tsx index d26cd7e56..400454d93 100644 --- a/src/js/views/feeds/Home.tsx +++ b/src/js/views/feeds/Home.tsx @@ -19,11 +19,13 @@ const Home: React.FC = () => { name: t('posts'), filter: { kinds: [1, 6], authors: followedUsers, limit: 10 }, filterFn: (event) => !getEventReplyingTo(event) || isRepost(event), + mergeReposts: true, eventProps: { showRepliedMsg: true }, }, { name: t('posts_and_replies'), filter: { kinds: [1, 6], authors: followedUsers, limit: 5 }, + mergeReposts: true, eventProps: { showRepliedMsg: true, fullWidth: false }, }, ],