8000 fix: squad post moderation list not updating by AmarTrebinjac · Pull Request #4458 · dailydotdev/apps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

AmarTrebinjac
Copy link
Contributor
@AmarTrebinjac AmarTrebinjac commented Apr 29, 2025

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

Copy link
vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
daily-webapp ✅ Ready (Inspect) Visit Preview May 5, 2025 5:59pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
storybook ⬜️ Ignored (Inspect) May 5, 2025 5:59pm

@AmarTrebinjac AmarTrebinjac changed the title Mi 825 fix: squad post moderation list not updating Apr 29, 2025
@AmarTrebinjac AmarTrebinjac marked this pull request as ready for review April 29, 2025 04:27
@AmarTrebinjac AmarTrebinjac requested a review from a team as a code owner April 29, 2025 04:27
Comment on lines -102 to 106
const listQueryKey = generateQueryKey(
const currentListKey = generateQueryKey(
RequestKey.SquadPostRequests,
user,
squad?.id,
);
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Member
@sshanzel sshanzel May 6, 2025

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),
Copy link
Member
@sshanzel sshanzel Apr 29, 2025 8000

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.

Copy link
Contributor Author

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.

Copy link
Member
@sshanzel sshanzel May 5, 2025

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.

Copy link
Member
@sshanzel sshanzel left a 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.

Copy link
Contributor
@capJavert capJavert left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0