fix: use resolvedFilter in subscription ID to fix $contacts alias

The real bug: subscription ID was using the original filter (with "$contacts" string)
while the query used the resolved filter (with actual pubkeys). This caused the
subscription to not re-subscribe when contacts were loaded.

Flow before fix:
1. Component renders, contacts = []
2. resolvedFilter has empty authors (since $contacts resolves to [])
3. Subscription ID: req-{"authors":["$contacts"]} (never changes)
4. Query sent with empty authors → no results
5. Contact list loads, contacts populates
6. resolvedFilter recalculates with real pubkeys
7. BUT subscription ID unchanged, so no re-subscribe!
8. Query stuck with empty authors

Flow after fix:
1. Subscription ID now uses resolvedFilter
2. When contacts load and resolvedFilter changes, ID changes
3. Hook detects new ID and creates new subscription with actual contact pubkeys
4. Query works correctly

Also includes the contactPointer memoization from previous commit.
This commit is contained in:
Claude
2025-12-22 22:15:26 +00:00
parent 63c77e8125
commit e9f6d5fc3a

View File

@@ -761,7 +761,7 @@ export default function ReqViewer({
relayStates: reqRelayStates,
overallState,
} = useReqTimelineEnhanced(
`req-${JSON.stringify(filter)}-${closeOnEose}`,
`req-${JSON.stringify(resolvedFilter)}-${closeOnEose}`,
resolvedFilter,
normalizedRelays,
{ limit: resolvedFilter.limit || 50, stream },