-
Notifications
You must be signed in to change notification settings - Fork 262
fix: squad post moderation list not updating #4458
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
const listQueryKey = generateQueryKey( | ||
const currentListKey = generateQueryKey( | ||
RequestKey.SquadPostRequests, | ||
user, | ||
squad?.id, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use only one using the squad.id
as discriminant field. Basically we have the squad list that has a specific id and the "all" list where this id is undefined
.
Have we tried to pass something like: squad?.id ?? "all"
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think the keys used are not matching with one another. It would be great if we continue the pattern Luca suggested above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't, because when the user is doing moderation for a single squad in for example /moderation/my-favorite-squad, when they approve/reject a post, the sidebar will not be updated because it uses a different key than the list that is being updated.
Remember, we are manually updating these in this component for optimistic updates. We need to access the keys specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, we will need to update two keys here. One for the specific squad and one for all
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also just invalidate [RequestKey.SquadPostRequests, user?.id]
that will invalidate both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do prefer to invalidate and refetch over manually updating then that is a possibility, yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking Lee is talking about invalidation here, my bad, if you want you can try new hooks for updating that I created after our gathering talks (they are merged already), WIP docs are https://dailydotdev.atlassian.net/wiki/spaces/HAN/pages/1556185091/Data+fetching+mutations+and+optimistic+updates+with+typed+queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, invalidation works, but the point about the query keys is my main concern. The issue is that there is a mismatch with the keys used across places, which makes the invalidation of one or the other not reflect the 100% correct data. So even if we invalidate or setData, the root cause is still there as you might not hit the right cache for the related areas.
squadId ?? 'all', | ||
status, | ||
), | ||
queryKey: generateQueryKey(RequestKey.SquadPostRequests, user, squadId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ideal to include the params we send as part of the query key. Let's keep the status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think including status requires us to pass it through a lot of places where we don't currently. It works well without it, so I think its better to leave it out for now and rather implement it when needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to have it on all places. Otherwise, we will just have issues when we try to toggle between statuses. It is always best to have them. If we want them to ensure consistency, we can introduce a generic function - but every param should be part of the query key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some comments about the query keys used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing beside what Lee said.
Changes
This should fix the pending posts not being refreshed after approving/rejecting, as well as update the count correctly in all the different places (both the ones counting a single squad, and the one counting all squads). To do this, I created another key for all squads. Might look a bit overkill, but this way we will always know which one is for all the squads, and we will always have access to it, regardless if we are in a tab that is using just the current squad list or not, and the sidebar will be updated correctly.
Events
Did you introduce any new tracking events?
Experiment
Did you introduce any new experiments?
Manual Testing
Caution
Please make sure existing components are not breaking/affected by this PR
Jira ticket
MI-825
Preview domain
https://mi-825.preview.app.daily.dev