Browse Source

bug-fixes

imwald
Silberengel 1 month ago
parent
commit
cde5be1bbb
  1. 16
      src/components/LiveActivitiesStrip.tsx
  2. 20
      src/components/NormalFeed/index.tsx
  3. 67
      src/components/NoteList/index.tsx
  4. 1
      src/components/Relay/index.tsx
  5. 4
      src/pages/primary/SpellsPage/index.tsx

16
src/components/LiveActivitiesStrip.tsx

@ -3,7 +3,7 @@ import { cn } from '@/lib/utils'
import { useLiveActivitiesOptional } from '@/providers/LiveActivitiesProvider' import { useLiveActivitiesOptional } from '@/providers/LiveActivitiesProvider'
import { useUserPreferences } from '@/providers/UserPreferencesProvider' import { useUserPreferences } from '@/providers/UserPreferencesProvider'
import { ExternalLink } from 'lucide-react' import { ExternalLink } from 'lucide-react'
import { useEffect, useState } from 'react' import { useEffect, useLayoutEffect, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
type TPlacement = 'sidebar' | 'mobile' type TPlacement = 'sidebar' | 'mobile'
@ -37,11 +37,21 @@ export default function LiveActivitiesStrip({ placement }: { placement: TPlaceme
return () => window.clearInterval(id) return () => window.clearInterval(id)
}, [items.length, reduceMotion]) }, [items.length, reduceMotion])
useLayoutEffect(() => {
if (items.length === 0) return
setSlide((s) => Math.min(s, items.length - 1))
}, [items.length])
if (!showLiveActivitiesBanner || items.length === 0) { if (!showLiveActivitiesBanner || items.length === 0) {
return null return null
} }
const current = items[slide]! // `items` can shrink without a new array identity; `slide` may then be out of range until effects run.
const displayIndex = Math.min(slide, items.length - 1)
const current = items[displayIndex]
if (!current) {
return null
}
return ( return (
<div <div
@ -100,7 +110,7 @@ export default function LiveActivitiesStrip({ placement }: { placement: TPlaceme
aria-label={t('liveActivities.goToSlide', { n: i + 1 })} aria-label={t('liveActivities.goToSlide', { n: i + 1 })}
className={cn( className={cn(
'size-1.5 rounded-full transition-colors', 'size-1.5 rounded-full transition-colors',
i === slide ? 'bg-primary' : 'bg-muted-foreground/40 hover:bg-muted-foreground/60' i === displayIndex ? 'bg-primary' : 'bg-muted-foreground/40 hover:bg-muted-foreground/60'
)} )}
onClick={(e) => { onClick={(e) => {
e.preventDefault() e.preventDefault()

20
src/components/NormalFeed/index.tsx

@ -28,10 +28,20 @@ const NormalFeed = forwardRef<TNoteListRef, {
mergeTimelineWhenSubRequestFiltersMatch?: boolean mergeTimelineWhenSubRequestFiltersMatch?: boolean
/** Home favorite-relays chip scope; see {@link NoteList} `feedTimelineScopeKey`. */ /** Home favorite-relays chip scope; see {@link NoteList} `feedTimelineScopeKey`. */
feedTimelineScopeKey?: string feedTimelineScopeKey?: string
/** Single-relay Explore / chip: kindless REQ (see `SINGLE_RELAY_KINDLESS_REQ_LIMIT` in constants), no feed kind filter. */ /** Single-relay Explore / chip: kindless REQ (see `SINGLE_RELAY_KINDLESS_REQ_LIMIT` in constants). */
useFilterAsIs?: boolean useFilterAsIs?: boolean
clientSideKindFilter?: boolean clientSideKindFilter?: boolean
allowKindlessRelayExplore?: boolean allowKindlessRelayExplore?: boolean
/**
* Default true (home following, favorites, sets, single-relay chip): kind picker narrows visible rows.
* Ignored when {@link showAllKinds} is effectively true.
*/
withKindFilter?: boolean
/**
* When true (relay explorer page), list shows the full relay batch. When omitted, uses KindFilter "All Events"
* ({@link useKindFilter} / persisted bypass) on home feeds.
*/
showAllKinds?: boolean
/** /**
* Client-side 🔍 feed filter. When omitted: hidden on main following, shown on relay explore and non-main feeds. * Client-side 🔍 feed filter. When omitted: hidden on main following, shown on relay explore and non-main feeds.
*/ */
@ -56,6 +66,8 @@ const NormalFeed = forwardRef<TNoteListRef, {
useFilterAsIs = false, useFilterAsIs = false,
clientSideKindFilter = false, clientSideKindFilter = false,
allowKindlessRelayExplore = false, allowKindlessRelayExplore = false,
withKindFilter = true,
showAllKinds: showAllKindsProp,
showFeedClientFilter: showFeedClientFilterProp, showFeedClientFilter: showFeedClientFilterProp,
hostPrimaryPageName, hostPrimaryPageName,
onSingleRelayKindlessEmpty, onSingleRelayKindlessEmpty,
@ -122,8 +134,10 @@ const NormalFeed = forwardRef<TNoteListRef, {
[showFeedClientFilterProp, isMainFeed, allowKindlessRelayExplore, useFilterAsIs] [showFeedClientFilterProp, isMainFeed, allowKindlessRelayExplore, useFilterAsIs]
) )
const listShowAllKinds = showAllKindsProp ?? feedKindFilterBypass
/** Include kind picker deps for single-relay chips (kindless REQ + client-side kinds). */ /** Include kind picker deps for single-relay chips (kindless REQ + client-side kinds). */
const subHeaderFilterDepsKey = `${allowKindlessRelayExplore ? 'kle' : 'std'}|${showKindsKey}|${feedKindFilterBypass}` const subHeaderFilterDepsKey = `${allowKindlessRelayExplore ? 'kle' : 'std'}|${showKindsKey}|${feedKindFilterBypass}|${listShowAllKinds ? 'all' : 'k'}`
const tabsElement = useMemo( const tabsElement = useMemo(
() => ( () => (
@ -209,6 +223,8 @@ const NormalFeed = forwardRef<TNoteListRef, {
showKind1Replies={showKind1Replies} showKind1Replies={showKind1Replies}
showKind1111={showKind1111} showKind1111={showKind1111}
seeAllFeedEvents={feedKindFilterBypass} seeAllFeedEvents={feedKindFilterBypass}
withKindFilter={withKindFilter}
showAllKinds={listShowAllKinds}
subRequests={subRequests} subRequests={subRequests}
hideReplies={listMode === 'posts'} hideReplies={listMode === 'posts'}
hideUntrustedNotes={hideUntrustedNotes} hideUntrustedNotes={hideUntrustedNotes}

67
src/components/NoteList/index.tsx

@ -215,7 +215,17 @@ const NoteList = forwardRef(
showKind1111 = true, showKind1111 = true,
seeAllFeedEvents = false, seeAllFeedEvents = false,
/** /**
* Single-relay Explore / home chip: REQ omits `kinds`, limit 200, no feed kind filter (relay decides what to send). * Default true: kind picker + kind-1 / 1111 splits narrow visible rows. False only when {@link showAllKinds}
* should win without listing every kind (rare).
*/
withKindFilter = true,
/**
* True on relay explorer and when KindFilter "All Events" is on (home): merged timeline is not narrowed to
* {@link showKinds} for display or live merge.
*/
showAllKinds = false,
/**
* Single-relay Explore / home chip: REQ omits `kinds`, relay limit (see `SINGLE_RELAY_KINDLESS_REQ_LIMIT`).
*/ */
allowKindlessRelayExplore = false, allowKindlessRelayExplore = false,
filterMutedNotes = true, filterMutedNotes = true,
@ -256,8 +266,8 @@ const NoteList = forwardRef(
timelineLoadingSafetyTimeoutMs, timelineLoadingSafetyTimeoutMs,
/** /**
* With {@link useFilterAsIs}: omit relay `kinds` when the subrequest filter has none. Kindless relay feeds * With {@link useFilterAsIs}: omit relay `kinds` when the subrequest filter has none. Kindless relay feeds
* merge the full batch; the kind picker still applies in the list via {@link applyKindPickerInUi}. Other * merge the full batch; {@link withKindFilter} + {@link showAllKinds} control whether {@link showKinds}
* `useFilterAsIs` paths may still narrow merged batches to {@link showKinds}. * narrows merge and visible rows. Other `useFilterAsIs` paths may still narrow merged batches to {@link showKinds}.
*/ */
clientSideKindFilter = false, clientSideKindFilter = false,
/** /**
@ -306,6 +316,8 @@ const NoteList = forwardRef(
showKind1111?: boolean showKind1111?: boolean
/** Omit REQ kinds and skip client-side kind filtering (main feed testing). Ignored when useFilterAsIs. */ /** Omit REQ kinds and skip client-side kind filtering (main feed testing). Ignored when useFilterAsIs. */
seeAllFeedEvents?: boolean seeAllFeedEvents?: boolean
withKindFilter?: boolean
showAllKinds?: boolean
allowKindlessRelayExplore?: boolean allowKindlessRelayExplore?: boolean
filterMutedNotes?: boolean filterMutedNotes?: boolean
hideReplies?: boolean hideReplies?: boolean
@ -580,7 +592,7 @@ const NoteList = forwardRef(
JSON.stringify({ JSON.stringify({
feed: timelineSubscriptionKey, feed: timelineSubscriptionKey,
...(allowKindlessRelayExplore ...(allowKindlessRelayExplore
? { relayKindless: true } ? { relayKindless: true, showAllKinds }
: { : {
kinds: showKindsKey, kinds: showKindsKey,
op: showKind1OPs, op: showKind1OPs,
@ -596,7 +608,8 @@ const NoteList = forwardRef(
showKind1Replies, showKind1Replies,
showKind1111, showKind1111,
seeAllFeedEvents, seeAllFeedEvents,
allowKindlessRelayExplore allowKindlessRelayExplore,
showAllKinds
] ]
) )
@ -615,17 +628,18 @@ const NoteList = forwardRef(
useFilterAsIsRef.current = useFilterAsIs useFilterAsIsRef.current = useFilterAsIs
const clientSideKindFilterRef = useRef(clientSideKindFilter) const clientSideKindFilterRef = useRef(clientSideKindFilter)
clientSideKindFilterRef.current = clientSideKindFilter clientSideKindFilterRef.current = clientSideKindFilter
const showAllKindsRef = useRef(showAllKinds)
showAllKindsRef.current = showAllKinds
const withKindFilterRef = useRef(withKindFilter)
withKindFilterRef.current = withKindFilter
/** /**
* When to apply kind picker + kind-1/1111/GitRelease visibility to visible rows. Kindless relay REQs merge * When to apply kind picker + kind-1 OP|reply / 1111 / GitRelease splits to visible rows.
* the full relay batch; this still filters what the list shows (unlike standalone relay explore, which sets * Home feeds default to {@link withKindFilter}; relay explorer and KindFilter "All Events" use {@link showAllKinds}.
* {@link allowKindlessRelayExplore} without {@link clientSideKindFilter} and shows the firehose).
*/ */
const applyKindPickerInUi = useMemo( const applyKindPickerInUi = useMemo(
() => () => withKindFilter && !showAllKinds && !seeAllFeedEvents,
!seeAllFeedEvents && [withKindFilter, showAllKinds, seeAllFeedEvents]
(!allowKindlessRelayExplore || (useFilterAsIs && clientSideKindFilter)),
[seeAllFeedEvents, allowKindlessRelayExplore, useFilterAsIs, clientSideKindFilter]
) )
const shouldHideEvent = useCallback( const shouldHideEvent = useCallback(
@ -1304,15 +1318,14 @@ const NoteList = forwardRef(
} }
/** /**
* Kindless relay REQ (`allowKindlessRelayExplore`): never drop events here relays return many kinds; * Kindless relay REQ: when {@link showAllKinds} is true (explorer / "All Events"), keep the full batch;
* merging only rows in {@link showKinds} left almost nothing in the timeline (e.g. christpill 200 events 1 * otherwise narrow to {@link showKinds} so the merged timeline matches {@link applyKindPickerInUi}.
* visible) while relay explore showed the full firehose. {@link applyKindPickerInUi} / {@link filteredEvents}
* still apply the kind picker for what the user sees.
*/ */
const narrowLiveBatch = (evs: Event[]) => { const narrowLiveBatch = (evs: Event[]) => {
if (seeAllFeedEventsRef.current) return evs if (seeAllFeedEventsRef.current) return evs
if (allowKindlessRelayExploreRef.current) return evs if (allowKindlessRelayExploreRef.current && showAllKindsRef.current) return evs
if (!useFilterAsIsRef.current || !clientSideKindFilterRef.current) return evs if (!useFilterAsIsRef.current || !clientSideKindFilterRef.current) return evs
if (!withKindFilterRef.current) return evs
return evs.filter((e) => showKinds.includes(e.kind)) return evs.filter((e) => showKinds.includes(e.kind))
} }
@ -1349,7 +1362,13 @@ 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 (useFilterAsIs && clientSideKindFilter && !seeAllFeedEventsRef.current) { if (
useFilterAsIs &&
clientSideKindFilter &&
withKindFilter &&
!seeAllFeedEventsRef.current &&
(!allowKindlessRelayExplore || !showAllKinds)
) {
merged = merged.filter((e) => showKinds.includes(e.kind)) merged = merged.filter((e) => showKinds.includes(e.kind))
} }
if (sessionSnap?.length && !userPulledRefresh) { if (sessionSnap?.length && !userPulledRefresh) {
@ -1579,7 +1598,10 @@ 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 (!seeAllFeedEventsRef.current && withKindFilterRef.current) {
const kindlessFirehose =
allowKindlessRelayExploreRef.current && showAllKindsRef.current
if (!kindlessFirehose) {
if (!useFilterAsIsRef.current && !showKinds.includes(event.kind)) return if (!useFilterAsIsRef.current && !showKinds.includes(event.kind)) return
if ( if (
clientSideKindFilterRef.current && clientSideKindFilterRef.current &&
@ -1595,6 +1617,7 @@ const NoteList = forwardRef(
if (event.kind === ExtendedKind.COMMENT && !showKind1111) return if (event.kind === ExtendedKind.COMMENT && !showKind1111) return
if (event.kind === ExtendedKind.GIT_RELEASE && !showKind1OPs) return if (event.kind === ExtendedKind.GIT_RELEASE && !showKind1OPs) return
} }
}
if (shouldHideEventRef.current(event)) return if (shouldHideEventRef.current(event)) return
if (pubkey && event.pubkey === pubkey) { if (pubkey && event.pubkey === pubkey) {
// If the new event is from the current user, insert it directly into the feed // If the new event is from the current user, insert it directly into the feed
@ -1693,6 +1716,8 @@ const NoteList = forwardRef(
oneShotFirstRelayGraceMs, oneShotFirstRelayGraceMs,
clientSideKindFilter, clientSideKindFilter,
allowKindlessRelayExplore, allowKindlessRelayExplore,
showAllKinds,
withKindFilter,
onSingleRelayKindlessEmpty onSingleRelayKindlessEmpty
]) ])
@ -1971,7 +1996,9 @@ const NoteList = forwardRef(
const narrowLoadMore = const narrowLoadMore =
useFilterAsIsRef.current && useFilterAsIsRef.current &&
clientSideKindFilterRef.current && clientSideKindFilterRef.current &&
!seeAllFeedEventsRef.current withKindFilterRef.current &&
!seeAllFeedEventsRef.current &&
(!allowKindlessRelayExploreRef.current || !showAllKindsRef.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/components/Relay/index.tsx

@ -148,6 +148,7 @@ const Relay = forwardRef<
subRequests={relayFeedSubRequests} subRequests={relayFeedSubRequests}
useFilterAsIs useFilterAsIs
allowKindlessRelayExplore allowKindlessRelayExplore
showAllKinds
showFeedClientFilter showFeedClientFilter
hostPrimaryPageName={hostPrimaryPageName} hostPrimaryPageName={hostPrimaryPageName}
/> />

4
src/pages/primary/SpellsPage/index.tsx

@ -1689,7 +1689,9 @@ const SpellsPage = forwardRef<TPageRef>(function SpellsPage(
subRequests={subRequests} subRequests={subRequests}
feedSubscriptionKey={spellFeedSubscriptionKey} feedSubscriptionKey={spellFeedSubscriptionKey}
hostPrimaryPageName="spells" hostPrimaryPageName="spells"
showKinds={showKinds} showKinds={
selectedFauxSpell === 'notifications' ? NOTIFICATION_SPELL_KINDS : showKinds
}
spellFeedInstrumentToken={spellFeedInstrumentToken} spellFeedInstrumentToken={spellFeedInstrumentToken}
onSpellFeedFirstPaint={handleSpellFeedFirstPaint} onSpellFeedFirstPaint={handleSpellFeedFirstPaint}
timelineLoadingSafetyTimeoutMs={ timelineLoadingSafetyTimeoutMs={

Loading…
Cancel
Save