brian2509 / kangaroo

The monorepo for the Kangaroo app.
https://kangaroo-rouge.vercel.app
2 stars 0 forks source link

Make react-query sticker packs cache dependent on userId #117

Closed MKuijpers closed 1 year ago

MKuijpers commented 1 year ago

At the moment, the cache of sticker packs is independent of any user. If you were to logout and log in with a new user, the old cache of the previous user would still be valid until the next request fetches the stickerpacks of the new user.

This can be fixed by making the query key of all /me-based queries based on the userId. For example QUERY_KEYS.myStickerPacks should become something like [QUERY_KEYS.myStickerPacks, userId].

MKuijpers commented 1 year ago

Fixed in 860a1c18dab275770d5bfe2bfa808b0ee2301bbb in PR #113 (not merged at time of posting)

Instead of using userId, this fixes the problem of showing data of previously logged-in users by just clearing the react-query cache on logout.