Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Info
Implemented improvement suggested here: https://discordapp.com/channels/573028991527550986/1012204566122598431/1197469917071548436
Since cookies do not store a date created attribute, the idea is that whenever the user cookie is set on the client, it is given a maxAge of 5 minutes, after which it is automatically deleted on the browser. Since the auth token has a lifespan of 2 weeks, it can be used repeatedly to re-generate the user cookie whenever it expires and deletes. (When the auth token expires, we are forced to logout to re-generate a new one).
This solves the problem of requesting an up-to-date version of the user object on every single page that needs it because now they will all rely on the shared cookie and this cookie itself will be updated whenever it is needed and does not exist.
This improvement relies on the assumption that any client side API modifications to the user object will also update it in real-time such as the way the edit profile functions so it is never out of sync with the API on a single device.
The only edge case that will fail is checking into an event or editing a user profile on 2 separate devices in under 5 minutes, which may display a invalid UI for this duration until it get's wiped and updated to the correct data subsequently.
With this change, the user API will be hit once every 5 minutes at most instead of on every page route change.
Changes
Type of Change
expected)
linting/formatting)
workflows)
Testing
I have tested that my changes fully resolve the linked issue ...
Checklist
/src/lib/*
and commented hard to understand areasanywhere else.
Screenshots