You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the concept I was going for was eliminating the 'nullish' portion of these types, making them straight booleans. Then, checking whether we've finished loading can be done with a separate, third variable, `loading`. The `admin` and `member` properties can be `false` by default, assuming an unauthenticated state.
The reason why we're concerned with loading is in the NavBar when we're still figuring out if a user is authenticated, and changing whether to show 'Login' or 'Register'. That flash of unauthenticated content, or whatever you want to call it, is confusing.
Like, what would you think if you logged onto a website and it said 'Login' and then 0.5 seconds later it flashes to "Hello, {name}"? That's the purpose of the skeleton components (the loading indicator).
That said, the current types bother me; we're already executing two separate routes - login checks for both the member and admin sides, every single time. Even normal users do it. And while tRPC is nice and bundles them together - I think we could do with a singular login route and abstracting the loading logic to a separate variable.
Pros:
Single route, better performance
Get rid of nullish values
More explicit meaning of what is being checked with 'loading'
We could do "loadingAuthentication" or "loadingContext" or something else, but the other variables are about the same in terms of naming & understanding. Null values have no explicit meaning.
Cons:
Can no longer have individual loading states for admin & member authentication - in the global context. Not much of a loss, really.
Minor refactor. Typescript should raise all the usage points, so it shouldn't be hard to find where to refactor. Search or find usages & whatever.
The reason why we're concerned with loading is in the NavBar when we're still figuring out if a user is authenticated, and changing whether to show 'Login' or 'Register'. That flash of unauthenticated content, or whatever you want to call it, is confusing.
Like, what would you think if you logged onto a website and it said 'Login' and then 0.5 seconds later it flashes to "Hello, {name}"? That's the purpose of the skeleton components (the loading indicator).
That said, the current types bother me; we're already executing two separate routes - login checks for both the member and admin sides, every single time. Even normal users do it. And while tRPC is nice and bundles them together - I think we could do with a singular login route and abstracting the loading logic to a separate variable.
Pros:
Cons:
Originally posted by @Xevion in #27 (comment)
The text was updated successfully, but these errors were encountered: