fix: Progress Tracking#494
Conversation
joneugster
left a comment
There was a problem hiding this comment.
Thanks for the PR! I'll have a closer look later
| const worldProgress = get(worldProgressAtom) | ||
| if (!levelId || !worldProgress) return | ||
| const copied = { ...worldProgress } | ||
| if (levelId == null) return |
There was a problem hiding this comment.
this is likely correct for when levelId is 0 but I need to check this later
There was a problem hiding this comment.
It's not the same behaviour since 0 is falsy, I've updated it so worldProgressAtom does not get updated when we are in level 0.
| @@ -0,0 +1,12 @@ | |||
| import { LevelProgress, WorldProgress } from "./progress-types" | |||
|
|
|||
| export const createDefaultWorldProgress = (): WorldProgress => ({ | |||
There was a problem hiding this comment.
Id prefer to use the style export function ... project wide, could you change to that, please? Also, is the as necessary?
There was a problem hiding this comment.
or even better,
this doesn't need to be a create-function does it? This can simply be a constant
const defaultLevelProgress: LevelProgress = {
...
}
There was a problem hiding this comment.
I've updated it to be a constant, and put it under defaultProgress in progress-atoms.ts.
| (get, set, val: boolean) => { | ||
| const levelProgress = get(levelProgressAtom) | ||
| if (!levelProgress) return | ||
| const levelProgress = get(levelProgressAtom) ?? createDefaultLevelProgress() |
There was a problem hiding this comment.
Have you consodered if it would make sense that levelProgressAtom directly returns a default, so thos doesn't need to be added in multiple places?
There was a problem hiding this comment.
I made levelProgressAtom and worldProgressAtom directly return the defaults, but still ended up adding those defaults in multiple places cause levelProgressAtom is allowed to return null when there is no worldId/progress/levelId/levelProgress. I'm looking through to see if I can take out checks like that so it returns the default value or actual value all the time, then I can remove the default values from other places.
|
I just noticed a new issue, one that was being blocked earlier cause progress was not being properly updated.
I don't know if I should address it here or leave it for another PR so this one does not go out of scope too much. |
reading to=>writing to.closes: #489