Browse Source

bug-fixes

imwald
Silberengel 1 month ago
parent
commit
9f8d3a23b7
  1. 22
      src/components/NormalFeed/index.tsx
  2. 59
      src/components/NoteList/index.tsx
  3. 1
      src/pages/primary/NoteListPage/RelaysFeed.tsx

22
src/components/NormalFeed/index.tsx

@ -104,9 +104,8 @@ const NormalFeed = forwardRef<TNoteListRef, {
[showFeedClientFilterProp, isMainFeed, allowKindlessRelayExplore, useFilterAsIs] [showFeedClientFilterProp, isMainFeed, allowKindlessRelayExplore, useFilterAsIs]
) )
const subHeaderFilterDepsKey = allowKindlessRelayExplore /** Include kind picker deps for single-relay chips (kindless REQ + client-side kinds). */
? 'kindless-relay-explore' const subHeaderFilterDepsKey = `${allowKindlessRelayExplore ? 'kle' : 'std'}|${showKindsKey}|${feedKindFilterBypass}`
: `${showKindsKey}|${feedKindFilterBypass}`
const tabsElement = ( const tabsElement = (
<Tabs <Tabs
@ -116,26 +115,15 @@ const NormalFeed = forwardRef<TNoteListRef, {
options={ options={
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
{onSubHeaderRefresh != null && <RefreshButton onClick={onSubHeaderRefresh} />} {onSubHeaderRefresh != null && <RefreshButton onClick={onSubHeaderRefresh} />}
{!allowKindlessRelayExplore && ( <KindFilter showKinds={showKinds} onShowKindsChange={handleShowKindsChange} />
<KindFilter showKinds={showKinds} onShowKindsChange={handleShowKindsChange} />
)}
</div> </div>
} }
/> />
) )
/** Same row for multi-relay and single-relay chips: Notes/Replies + refresh + kind picker (REQ may stay kindless for single relay; NoteList filters client-side). */
useLayoutEffect(() => { useLayoutEffect(() => {
if (!isMainFeed || !setSubHeader) return if (!isMainFeed || !setSubHeader) return
if (allowKindlessRelayExplore) {
setSubHeader(
onSubHeaderRefresh != null ? (
<div className="flex w-full items-center justify-end gap-1">
<RefreshButton onClick={onSubHeaderRefresh} />
</div>
) : null
)
return () => setSubHeader(null)
}
setSubHeader(tabsElement) setSubHeader(tabsElement)
return () => setSubHeader(null) return () => setSubHeader(null)
}, [ }, [
@ -161,7 +149,7 @@ const NormalFeed = forwardRef<TNoteListRef, {
showKind1111={showKind1111} showKind1111={showKind1111}
seeAllFeedEvents={feedKindFilterBypass} seeAllFeedEvents={feedKindFilterBypass}
subRequests={subRequests} subRequests={subRequests}
hideReplies={allowKindlessRelayExplore ? false : listMode === 'posts'} hideReplies={listMode === 'posts'}
hideUntrustedNotes={hideUntrustedNotes} hideUntrustedNotes={hideUntrustedNotes}
areAlgoRelays={areAlgoRelays} areAlgoRelays={areAlgoRelays}
relayCapabilityReady={relayCapabilityReady} relayCapabilityReady={relayCapabilityReady}

59
src/components/NoteList/index.tsx

@ -446,6 +446,17 @@ const NoteList = forwardRef(
const clientSideKindFilterRef = useRef(clientSideKindFilter) const clientSideKindFilterRef = useRef(clientSideKindFilter)
clientSideKindFilterRef.current = clientSideKindFilter clientSideKindFilterRef.current = clientSideKindFilter
/**
* When to apply kind picker + kind-1/1111/GitRelease visibility to rows. Kindless home relay chips use a
* kindless REQ and narrow here via {@link clientSideKindFilter}; standalone relay explore keeps firehose.
*/
const applyKindPickerInUi = useMemo(
() =>
!seeAllFeedEvents &&
(!allowKindlessRelayExplore || (useFilterAsIs && clientSideKindFilter)),
[seeAllFeedEvents, allowKindlessRelayExplore, useFilterAsIs, clientSideKindFilter]
)
const shouldHideEvent = useCallback( const shouldHideEvent = useCallback(
(evt: Event) => { (evt: Event) => {
const pinnedEventHexIdSet = new Set() const pinnedEventHexIdSet = new Set()
@ -509,7 +520,7 @@ const NoteList = forwardRef(
const idSet = new Set<string>() const idSet = new Set<string>()
return events.slice(0, showCount).filter((evt) => { return events.slice(0, showCount).filter((evt) => {
if (!seeAllFeedEvents && !allowKindlessRelayExplore) { if (applyKindPickerInUi) {
if (!showKinds.includes(evt.kind)) return false if (!showKinds.includes(evt.kind)) return false
// Kind 1: show only OPs if showKind1OPs, only replies if showKind1Replies // Kind 1: show only OPs if showKind1OPs, only replies if showKind1Replies
if (evt.kind === kinds.ShortTextNote) { if (evt.kind === kinds.ShortTextNote) {
@ -539,8 +550,7 @@ const NoteList = forwardRef(
showKind1OPs, showKind1OPs,
showKind1Replies, showKind1Replies,
showKind1111, showKind1111,
seeAllFeedEvents, applyKindPickerInUi
allowKindlessRelayExplore
]) ])
useLayoutEffect(() => { useLayoutEffect(() => {
@ -586,7 +596,7 @@ const NoteList = forwardRef(
const idSet = new Set<string>() const idSet = new Set<string>()
return newEvents.filter((event: Event) => { return newEvents.filter((event: Event) => {
if (!seeAllFeedEvents && !allowKindlessRelayExplore) { if (applyKindPickerInUi) {
if (!showKinds.includes(event.kind)) return false if (!showKinds.includes(event.kind)) return false
if (event.kind === kinds.ShortTextNote) { if (event.kind === kinds.ShortTextNote) {
const isReply = isReplyNoteEvent(event) const isReply = isReplyNoteEvent(event)
@ -614,8 +624,7 @@ const NoteList = forwardRef(
showKind1OPs, showKind1OPs,
showKind1Replies, showKind1Replies,
showKind1111, showKind1111,
seeAllFeedEvents, applyKindPickerInUi
allowKindlessRelayExplore
]) ])
const feedClientMinCreatedAt = useMemo(() => { const feedClientMinCreatedAt = useMemo(() => {
@ -967,8 +976,17 @@ const NoteList = forwardRef(
} }
const narrowLiveBatch = (evs: Event[]) => { const narrowLiveBatch = (evs: Event[]) => {
if (seeAllFeedEventsRef.current || allowKindlessRelayExploreRef.current) return evs if (seeAllFeedEventsRef.current) return evs
if (!useFilterAsIs || !clientSideKindFilter) return evs if (
allowKindlessRelayExploreRef.current &&
!(useFilterAsIsRef.current && clientSideKindFilterRef.current)
) {
return evs
}
if (!useFilterAsIsRef.current || !clientSideKindFilterRef.current) {
if (!allowKindlessRelayExploreRef.current) return evs
return evs
}
return evs.filter((e) => showKinds.includes(e.kind)) return evs.filter((e) => showKinds.includes(e.kind))
} }
@ -1004,12 +1022,7 @@ const NoteList = forwardRef(
let merged = [...byId.values()] let merged = [...byId.values()]
.sort((a, b) => b.created_at - a.created_at) .sort((a, b) => b.created_at - a.created_at)
.slice(0, cap) .slice(0, cap)
if ( if (useFilterAsIs && clientSideKindFilter && !seeAllFeedEventsRef.current) {
useFilterAsIs &&
clientSideKindFilter &&
!seeAllFeedEventsRef.current &&
!allowKindlessRelayExploreRef.current
) {
merged = merged.filter((e) => showKinds.includes(e.kind)) merged = merged.filter((e) => showKinds.includes(e.kind))
} }
if (sessionSnap?.length && !userPulledRefresh) { if (sessionSnap?.length && !userPulledRefresh) {
@ -1211,9 +1224,18 @@ const NoteList = forwardRef(
onNew: (event: Event) => { onNew: (event: Event) => {
if (!effectActive) return if (!effectActive) return
feedRelayReturnedAnyEventRef.current = true feedRelayReturnedAnyEventRef.current = true
if (!seeAllFeedEventsRef.current && !allowKindlessRelayExploreRef.current) { if (
if (!useFilterAsIs && !showKinds.includes(event.kind)) return !seeAllFeedEventsRef.current &&
if (clientSideKindFilter && useFilterAsIs && !showKinds.includes(event.kind)) return (!allowKindlessRelayExploreRef.current ||
(useFilterAsIsRef.current && clientSideKindFilterRef.current))
) {
if (!useFilterAsIsRef.current && !showKinds.includes(event.kind)) return
if (
clientSideKindFilterRef.current &&
useFilterAsIsRef.current &&
!showKinds.includes(event.kind)
)
return
if (event.kind === kinds.ShortTextNote) { if (event.kind === kinds.ShortTextNote) {
const isReply = isReplyNoteEvent(event) const isReply = isReplyNoteEvent(event)
if (isReply && !showKind1Replies) return if (isReply && !showKind1Replies) return
@ -1586,8 +1608,7 @@ const NoteList = forwardRef(
const narrowLoadMore = const narrowLoadMore =
useFilterAsIsRef.current && useFilterAsIsRef.current &&
clientSideKindFilterRef.current && clientSideKindFilterRef.current &&
!seeAllFeedEventsRef.current && !seeAllFeedEventsRef.current
!allowKindlessRelayExploreRef.current
let toAppend = narrowLoadMore let toAppend = narrowLoadMore
? fetchBatch.filter((e) => showKindsRef.current.includes(e.kind)) ? fetchBatch.filter((e) => showKindsRef.current.includes(e.kind))
: fetchBatch : fetchBatch

1
src/pages/primary/NoteListPage/RelaysFeed.tsx

@ -132,6 +132,7 @@ const RelaysFeed = forwardRef<
feedTimelineScopeKey={feedTimelineScopeKey} feedTimelineScopeKey={feedTimelineScopeKey}
useFilterAsIs={singleRelayKindlessExplore} useFilterAsIs={singleRelayKindlessExplore}
allowKindlessRelayExplore={singleRelayKindlessExplore} allowKindlessRelayExplore={singleRelayKindlessExplore}
clientSideKindFilter={singleRelayKindlessExplore}
showFeedClientFilter showFeedClientFilter
/> />
) )

Loading…
Cancel
Save