diff --git a/src/components/Filters/FeedFilter.tsx b/src/components/Filters/FeedFilter.tsx
index e3718a4..655d039 100644
--- a/src/components/Filters/FeedFilter.tsx
+++ b/src/components/Filters/FeedFilter.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import { PropsWithChildren } from 'react'
import { Filter } from '.'
-import { FilterOptions, SortBy } from 'types'
+import { FilterOptions, RepostFilter, SortBy } from 'types'
import { Dropdown } from './Dropdown'
import { Option } from './Option'
import { DEFAULT_FILTER_OPTIONS } from 'utils'
@@ -86,6 +86,27 @@ export const FeedFilter = React.memo(
)}
+ {/* Repost filter */}
+ {tab === 2 && (
+
+ {Object.values(RepostFilter).map((item, index) =>
+ item === RepostFilter.Only_Repost ? null : (
+
+ )
+ )}
+
+ )}
+
{children}
)
diff --git a/src/pages/feed/FeedTabPosts.tsx b/src/pages/feed/FeedTabPosts.tsx
index 4fd7e40..74008a8 100644
--- a/src/pages/feed/FeedTabPosts.tsx
+++ b/src/pages/feed/FeedTabPosts.tsx
@@ -1,6 +1,6 @@
import { useLoaderData } from 'react-router-dom'
import { FeedPageLoaderResult } from './loader'
-import { useAppSelector, useNDKContext } from 'hooks'
+import { useAppSelector, useLocalStorage, useNDKContext } from 'hooks'
import { useEffect, useMemo, useState } from 'react'
import { LoadingSpinner } from 'components/LoadingSpinner'
import {
@@ -11,6 +11,8 @@ import {
} from '@nostr-dev-kit/ndk'
import { NoteSubmit } from 'components/Notes/NoteSubmit'
import { Note } from 'components/Notes/Note'
+import { FeedPostsFilter, RepostFilter } from 'types'
+import { DEFAULT_FILTER_OPTIONS } from 'utils'
export const FeedTabPosts = () => {
const SHOWING_STEP = 20
@@ -24,6 +26,12 @@ export const FeedTabPosts = () => {
const [isLoadMoreVisible, setIsLoadMoreVisible] = useState(true)
const [showing, setShowing] = useState(SHOWING_STEP)
+ const filterKey = 'filter-feed-2'
+ const [filterOptions] = useLocalStorage(
+ filterKey,
+ DEFAULT_FILTER_OPTIONS
+ )
+
useEffect(() => {
if (!userPubkey) return
@@ -65,14 +73,23 @@ export const FeedTabPosts = () => {
// )
// )
- // Filter reply events
- _notes = _notes.filter((n) => n.getMatchingTags('e').length === 0)
+ _notes = _notes.filter((n) => {
+ if (n.kind === NDKKind.Text) {
+ // Filter out the replies (Kind 1 events with e tags are replies to other kind 1 events)
+ return n.getMatchingTags('e').length === 0
+ }
+ // Filter repost events if the option is set to hide reposts
+ return !(
+ n.kind === NDKKind.Repost &&
+ filterOptions.repost === RepostFilter.Hide_Repost
+ )
+ })
_notes = _notes.sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0))
showing > 0 && _notes.splice(showing)
return _notes
- }, [notes, showing])
+ }, [filterOptions.repost, notes, showing])
if (!userPubkey) return null
diff --git a/src/types/modsFilter.ts b/src/types/modsFilter.ts
index 6cf8dc3..22e0982 100644
--- a/src/types/modsFilter.ts
+++ b/src/types/modsFilter.ts
@@ -41,4 +41,4 @@ export interface FilterOptions {
repost: RepostFilter
}
-export type FeedPostsFilter = Pick
+export type FeedPostsFilter = Pick