mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-07 01:55:51 +08:00
Persist learn progress per user
This commit is contained in:
38
shared/learn/config.ts
Normal file
38
shared/learn/config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
export interface LessonProgress {
|
||||
best: number
|
||||
done: boolean
|
||||
}
|
||||
|
||||
export type LearnProgress = Record<string, Record<string, LessonProgress>>
|
||||
|
||||
export interface LearnConfig {
|
||||
tts: boolean
|
||||
radioLevel: number
|
||||
voice: string
|
||||
audioChallenge: boolean
|
||||
}
|
||||
|
||||
export interface LearnState {
|
||||
xp: number
|
||||
progress: LearnProgress
|
||||
config: LearnConfig
|
||||
}
|
||||
|
||||
export const LEARN_CONFIG_DEFAULTS: LearnConfig = {
|
||||
tts: false,
|
||||
radioLevel: 4,
|
||||
voice: '',
|
||||
audioChallenge: false,
|
||||
}
|
||||
|
||||
export function createDefaultLearnConfig(): LearnConfig {
|
||||
return { ...LEARN_CONFIG_DEFAULTS }
|
||||
}
|
||||
|
||||
export function createDefaultLearnState(): LearnState {
|
||||
return {
|
||||
xp: 0,
|
||||
progress: {} as LearnProgress,
|
||||
config: createDefaultLearnConfig(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user