feat: show relay close reasons in certain feeds
This commit is contained in:
parent
c110b303d7
commit
9267458bca
7 changed files with 35 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import NoteList, { TNoteListRef } from '@/components/NoteList'
|
||||
import Tabs from '@/components/Tabs'
|
||||
import { isTouchDevice } from '@/lib/utils'
|
||||
import { useKindFilter } from '@/providers/KindFilterProvider'
|
||||
import { useUserTrust } from '@/providers/UserTrustProvider'
|
||||
import storage from '@/services/local-storage.service'
|
||||
|
|
@ -7,16 +8,17 @@ import { TFeedSubRequest, TNoteListMode } from '@/types'
|
|||
import { useMemo, useRef, useState } from 'react'
|
||||
import KindFilter from '../KindFilter'
|
||||
import { RefreshButton } from '../RefreshButton'
|
||||
import { isTouchDevice } from '@/lib/utils'
|
||||
|
||||
export default function NormalFeed({
|
||||
subRequests,
|
||||
areAlgoRelays = false,
|
||||
isMainFeed = false
|
||||
isMainFeed = false,
|
||||
showRelayCloseReason = false
|
||||
}: {
|
||||
subRequests: TFeedSubRequest[]
|
||||
areAlgoRelays?: boolean
|
||||
isMainFeed?: boolean
|
||||
showRelayCloseReason?: boolean
|
||||
}) {
|
||||
const { hideUntrustedNotes } = useUserTrust()
|
||||
const { showKinds } = useKindFilter()
|
||||
|
|
@ -63,6 +65,7 @@ export default function NormalFeed({
|
|||
hideReplies={listMode === 'posts'}
|
||||
hideUntrustedNotes={hideUntrustedNotes}
|
||||
areAlgoRelays={areAlgoRelays}
|
||||
showRelayCloseReason={showRelayCloseReason}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import {
|
|||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import PullToRefresh from 'react-simple-pull-to-refresh'
|
||||
import { toast } from 'sonner'
|
||||
import NoteCard, { NoteCardLoadingSkeleton } from '../NoteCard'
|
||||
|
||||
const LIMIT = 200
|
||||
|
|
@ -41,7 +42,8 @@ const NoteList = forwardRef(
|
|||
filterMutedNotes = true,
|
||||
hideReplies = false,
|
||||
hideUntrustedNotes = false,
|
||||
areAlgoRelays = false
|
||||
areAlgoRelays = false,
|
||||
showRelayCloseReason = false
|
||||
}: {
|
||||
subRequests: TFeedSubRequest[]
|
||||
showKinds: number[]
|
||||
|
|
@ -49,6 +51,7 @@ const NoteList = forwardRef(
|
|||
hideReplies?: boolean
|
||||
hideUntrustedNotes?: boolean
|
||||
areAlgoRelays?: boolean
|
||||
showRelayCloseReason?: boolean
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
|
|
@ -184,6 +187,11 @@ const NoteList = forwardRef(
|
|||
[event, ...oldEvents].sort((a, b) => b.created_at - a.created_at)
|
||||
)
|
||||
}
|
||||
},
|
||||
onClose: (url, reason) => {
|
||||
if (!showRelayCloseReason) return
|
||||
if (reason === 'closed by caller') return
|
||||
toast.error(`${url}: ${reason}`)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ export default function Relay({ url, className }: { url?: string; className?: st
|
|||
subRequests={[
|
||||
{ urls: [normalizedUrl], filter: debouncedInput ? { search: debouncedInput } : {} }
|
||||
]}
|
||||
showRelayCloseReason
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export default function SearchResult({ searchParams }: { searchParams: TSearchPa
|
|||
return (
|
||||
<NormalFeed
|
||||
subRequests={[{ urls: SEARCHABLE_RELAY_URLS, filter: { search: searchParams.search } }]}
|
||||
showRelayCloseReason
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
@ -27,6 +28,7 @@ export default function SearchResult({ searchParams }: { searchParams: TSearchPa
|
|||
return (
|
||||
<NormalFeed
|
||||
subRequests={[{ urls: BIG_RELAY_URLS, filter: { '#t': [searchParams.search] } }]}
|
||||
showRelayCloseReason
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue