File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
- import { CompletedQuizzes , UserStats } from "@/lib/types"
2
-
3
- import allQuizzesData from "@/data/quizzes"
1
+ import { UserStats } from "@/lib/types"
4
2
5
3
import { USER_STATS_KEY } from "@/lib/constants"
6
4
@@ -15,5 +13,13 @@ export const INITIAL_USER_STATS: UserStats = {
15
13
export const useLocalQuizData = ( ) => {
16
14
const data = useLocalStorage ( USER_STATS_KEY , INITIAL_USER_STATS )
17
15
16
+ // If the user has an old version of the app, convert the
17
+ // `completed` value from a string to an object.
18
+ const [ current , setCurrent ] = data
19
+ if ( typeof current . completed === "string" ) {
20
+ const newCompleted = JSON . parse ( current . completed )
21
+ setCurrent ( { ...current , completed : newCompleted } )
22
+ }
23
+
18
24
return data
19
25
}
You can’t perform that action at this time.
0 commit comments