stacker.news icon indicating copy to clipboard operation
stacker.news copied to clipboard

fix(Mention): Maintain mention after nym change

Open brymut opened this issue 3 months ago • 2 comments

Description

Changing nym should still point to the user mentioned instead of losing link.

fixes #2232

Tested scenarios with screen recording:

  1. Simple nym change

https://github.com/user-attachments/assets/917c4d6d-02ba-4625-9042-729198c429f8

  1. Nym change with multiple mentions in one post. Changing both should mentions should point mentions to new nyms

https://github.com/user-attachments/assets/38fcdbc7-a1f7-4830-84cb-7603365b5edd

  1. Nym change and then a third party claims originally mentioned nym. The mentioned profile at the point of post creation should be the one linked, even if someone else claims the nym later on.

https://github.com/user-attachments/assets/0597e1f0-42cc-4d30-a452-f125e87b10b3

Checklist

Are your changes backward compatible? Please answer below: Y

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below: 10

For frontend changes: Tested on mobile, light and dark mode? Please answer below: Y

Did you introduce any new environment variables? If so, call them out explicitly here: N

Did you use AI for this? If so, how much did it assist you? Y. Mostly gathering context on how mentions are stored in DB and helping me debug ordering problem of mentions.


[!NOTE] Resolve mentions to the correct user even after username changes by adding userByMention GraphQL query and wiring frontend mention/popover to use it with itemId.

  • GraphQL/API:
    • Add Query.userByMention(name: String!, itemId: ID): User with resolver that resolves a user from Mention records for a given itemId, falling back to user(name).
  • Frontend:
    • components/text.js: Pass itemId into mention renderer and UserPopover; dynamically link mentions to /${user.name} when resolved. Update useMemo deps to include itemId.
    • components/user-popover.js: Query USER_BY_MENTION (when itemId provided) and fall back to USER; expose resolved user to children; refine loading and display logic.
  • GQL Fragments:
    • Add USER_BY_MENTION query in fragments/users.js.

Written by Cursor Bugbot for commit 0f58cd20987d7ad6c5bcf41fe69d67657d0de345. This will update automatically on new commits. Configure here.

brymut avatar Sep 30 '25 14:09 brymut

Hi @Soxasora, let me re-familiarise myself, will rebase and update this PR and get back to you if that's ok.

brymut avatar Nov 13 '25 14:11 brymut

Hi @Soxasora, sorry for the force pushing again. Noticed my original solution hadn't properly factored in the order in which mentions are stored in the DB and multiple mentions in the same post. Updated the screen recording in the PR description with those test cases. Should be good to be used, let me know if you have any questions.

brymut avatar Nov 26 '25 16:11 brymut