stacker.news
stacker.news copied to clipboard
fix(Mention): Maintain mention after nym change
Description
Changing nym should still point to the user mentioned instead of losing link.
fixes #2232
Tested scenarios with screen recording:
- Simple nym change
https://github.com/user-attachments/assets/917c4d6d-02ba-4625-9042-729198c429f8
- 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
- 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
userByMentionGraphQL query and wiring frontend mention/popover to use it withitemId.
- GraphQL/API:
- Add
Query.userByMention(name: String!, itemId: ID): Userwith resolver that resolves a user fromMentionrecords for a givenitemId, falling back touser(name).- Frontend:
components/text.js: PassitemIdintomentionrenderer andUserPopover; dynamically link mentions to/${user.name}when resolved. UpdateuseMemodeps to includeitemId.components/user-popover.js: QueryUSER_BY_MENTION(whenitemIdprovided) and fall back toUSER; expose resolved user to children; refine loading and display logic.- GQL Fragments:
- Add
USER_BY_MENTIONquery infragments/users.js.Written by Cursor Bugbot for commit 0f58cd20987d7ad6c5bcf41fe69d67657d0de345. This will update automatically on new commits. Configure here.
Hi @Soxasora, let me re-familiarise myself, will rebase and update this PR and get back to you if that's ok.
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.