diff --git a/frontend/src/components/Checkpoint/checkpoint.ts b/frontend/src/components/Checkpoint/checkpoint.ts index 9e642cf..c2b46d9 100644 --- a/frontend/src/components/Checkpoint/checkpoint.ts +++ b/frontend/src/components/Checkpoint/checkpoint.ts @@ -1,23 +1,30 @@ type Checkpoints = Map>; class Persistent { - persistent: Checkpoints = new Map>(); + persistent: Checkpoints = new Map(); subscribers: Array<(checkpoints: Checkpoints) => void> = []; constructor() { this.persistent = this.deserialize(); } - + private serialize() { const serialized: Array<[string, string[]]> = [ ...this.persistent.entries(), ].map(([k, v]) => [k, Array.from(v)]); localStorage.setItem("checkpoints", JSON.stringify(serialized)); } - + + /* Old format + {"data":[["#$@__reference__1","1",{"data":["1-1"],"#$@__constructor__":"Set","#$@__reference__":2}],["#$@__reference__3","2",{"data":["2-1","2-2","2-3","2-4","2-5","2-6","2-7","2-8","2-confetti"],"#$@__constructor__":"Set","#$@__reference__":4}],["#$@__reference__5","3",{"data":["3-1"],"#$@__constructor__":"Set","#$@__reference__":6}],["#$@__reference__7","4",{"data":["4-1"],"#$@__constructor__":"Set","#$@__reference__":8}]],"#$@__constructor__":"Map","#$@__reference__":0} + */ private deserialize(): Checkpoints { const item = localStorage.getItem("checkpoints") as string; const parsed: Array<[string, string[]]> = (item && JSON.parse(item)) || []; + if (!Array.isArray(parsed)) { + window.alert("Failed to load checkpoints, resetting progress.") + return new Map(); + } return new Map(parsed.map(([k, v]) => [k, new Set(v)])); } diff --git a/frontend/src/content/docs/en/first-steps/4-enrolling.mdx b/frontend/src/content/docs/en/first-steps/4-enrolling.mdx index ba0fd1d..c093d1b 100644 --- a/frontend/src/content/docs/en/first-steps/4-enrolling.mdx +++ b/frontend/src/content/docs/en/first-steps/4-enrolling.mdx @@ -42,7 +42,7 @@ Please fill in the remaining information in the blanks provided: :::caution[Data collection?] -**DATA WILL NOT BE COLLECTED** in any way, it's just an exercise. +**DATA WILL NOT BE COLLECTED** in any way, it's just for the exercise. If you're worried about it, use dummy values that don't match your real data. :::