forum: post score + highlight missing after page refresh on both list and detail views #65
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp#65
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Repro
What's going on (best read of the code)
Both views render
SubmissionWithMeta.votes.{score, userVote}. Thevotesfield is computed bySubmissionService.enrichSubmission()at the moment a kind-1111 event is parsed, then re-computed byrefreshAllSubmissionVotes()(list path) orrefreshSubmissionVotes(id)(detail path) on EOSE.Two plausible contributors, in order of suspected impact:
1. List subscription's reaction filter is too broad.
buildFilters()insrc/modules/forum/services/SubmissionService.tsships three filters; the reactions one is:— no
#escoping. On any relay with meaningful kind-7 volume, the 1000-event slice it returns may not contain the user's reactions to the posts currently in view. EOSE then fires,refreshAllSubmissionVotesruns against a ReactionService that simply doesn't have the relevant reactions, and votes stay at zero. When you open the detail page,subscribeToSubmission(id)requests{ kinds: 7, '#e': [submissionId] }which IS correctly scoped — those reactions land in ReactionService,refreshSubmissionVotes(id)reassignssubmission.votes, and Vue propagates the change to the row that's still mounted on the list (same reactive object in_submissions). That's the "navigating in/out fixes it" effect.Fix: scope the list reactions filter to the submission IDs we actually care about — fetch submissions in a first pass, then open a follow-up reactions subscription with
'#e': [...submission.ids](this is essentially whatReactionService.subscribeToReactions()is designed for atsrc/modules/base/nostr/ReactionService.ts:84).2. Auth-pubkey race on the userVote highlight.
Even when reactions DO arrive,
ReactionService.recalculateEventReactions()(src/modules/base/nostr/ReactionService.ts:237) computesuserHasLiked/userHasDislikedby comparingreaction.pubkey === authService.user.value?.pubkey(lines 271, 277). On refresh, the LNbits-backed auth state hydrates async; reactions that arrive before that hydration completes get counted in the score but never flagged as the user's own, so the arrow stays unhighlighted even when the score is right.Fix: in
ReactionService, watchauthService.user.value?.pubkey; on a falsy → truthy transition, re-runrecalculateEventReactionsacross all known event IDs.Notes