Skip to content

Commit

Permalink
repost merge improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalmi committed Aug 24, 2023
1 parent 23b9287 commit 2755f09
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/components/events/note/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 4 additions & 1 deletion src/js/components/feed/Feed.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -62,6 +62,9 @@ const Feed = (props: FeedProps) => {

const hiddenEvents = useMemo(() => {
const hiddenEvents = new Set<string>();
if (!filterOption.mergeReposts) {
return hiddenEvents;
}
const seenReposts = new Set<string>();
for (const event of events) {
if (isRepost(event)) {
Expand Down
1 change: 1 addition & 0 deletions src/js/components/feed/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export type FilterOption = {
filter: Filter;
filterFn?: (event: Event) => boolean;
eventProps?: Partial<EventComponentProps>;
mergeReposts?: boolean;
};
2 changes: 2 additions & 0 deletions src/js/views/feeds/Global.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ const Global: React.FC<RouteProps> = () => {
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,
},
],
[],
Expand Down
2 changes: 2 additions & 0 deletions src/js/views/feeds/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ const Home: React.FC<RouteProps> = () => {
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 },
},
],
Expand Down

0 comments on commit 2755f09

Please sign in to comment.