Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voting on a proposal in the chat room does not update the UI immediately, which also allows for multiple votes #538

Closed
tibetsprague opened this issue Apr 1, 2025 · 3 comments · Fixed by #546
Assignees

Comments

@tibetsprague
Copy link
Collaborator

No description provided.

@tibetsprague tibetsprague moved this to Backlog in Hylo Dev Apr 1, 2025
@tibetsprague tibetsprague moved this from Backlog to Current Sprint in Hylo Dev Apr 1, 2025
@thomasgwatson thomasgwatson self-assigned this Apr 2, 2025
@thomasgwatson thomasgwatson moved this from Current Sprint to In Progress in Hylo Dev Apr 2, 2025
@thomasgwatson
Copy link
Collaborator

I'm seeing that Reactions have these handlers

const onAddReaction = useCallback((post, emojiFull) => {
  const optimisticUpdate = { myReactions: [...post.myReactions, { emojiFull }], postReactions: [...post.postReactions, { emojiFull, user: { name: currentUser.name, id: currentUser.id } }] }
  const newPost = { ...post, ...optimisticUpdate }
  messageListRef.current?.data.map((item) => post.id === item.id || (post.localId && post.localId === item.localId) ? newPost : item)
}, [currentUser])

const onRemoveReaction = useCallback((post, emojiFull) => {
  const postReactions = post.postReactions.filter(reaction => {
    if (reaction.emojiFull === emojiFull && reaction.user.id === currentUser.id) return false
    return true
  })
  const newPost = { ...post, myReactions: post.myReactions.filter(react => react.emojiFull !== emojiFull), postReactions }
  messageListRef.current?.data.map((item) => post.id === item.id || (post.localId && post.localId === item.localId) ? newPost : item)
}, [currentUser])

Is this basically suggesting that we need to do specific manipulation of the virtuoso list to ensure that contents are re-rendered on votes?

@tibetsprague

@tibetsprague
Copy link
Collaborator Author

yes, see how we do it in onAddReaction in ChatRoom

@tibetsprague
Copy link
Collaborator Author

@thomasgwatson while you're at we should build in a safety check on the backend that only allows voting once per item

@thomasgwatson thomasgwatson moved this from In Progress to Review In Progress in Hylo Dev Apr 4, 2025
@github-project-automation github-project-automation bot moved this from Review In Progress to Merged to Dev in Hylo Dev Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged to Dev
Development

Successfully merging a pull request may close this issue.

2 participants