feat(vocab): implement repeat queue management in VocabService and VocabLessonView
All checks were successful
Deploy to production / deploy (push) Successful in 2m59s

- Added a new method in VocabService to sanitize and manage a repeat queue for vocabulary items, enhancing the learning process.
- Updated VocabLessonView to incorporate repeat queue functionality, allowing for better tracking of vocabulary that needs review.
- Refactored existing logic to ensure seamless integration of repeat queue features, improving user experience during vocabulary lessons.
This commit is contained in:
Torsten Schulz (local)
2026-04-01 14:06:34 +02:00
parent a3b820cea0
commit 09015b4244
2 changed files with 124 additions and 7 deletions

View File

@@ -115,6 +115,21 @@ export default class VocabService {
return sanitized;
}
_sanitizeRepeatQueue(value) {
if (!Array.isArray(value)) {
return [];
}
return value
.slice(0, 100)
.map((entry) => ({
key: this._sanitizeShortString(entry?.key, 200),
dueAfter: this._clampInteger(entry?.dueAfter, { min: 0, max: 50 }),
stageIndex: this._clampInteger(entry?.stageIndex, { min: 0, max: 10 })
}))
.filter((entry) => entry.key);
}
_sanitizeLessonState(value) {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
return {};
@@ -136,6 +151,7 @@ export default class VocabService {
'vocabTrainerCurrentAttempts',
'vocabTrainerReviewAttempts',
'vocabTrainerStats',
'vocabTrainerRepeatQueue',
'exerciseAnswers',
'exerciseResults',
'exerciseRetryPending',
@@ -165,6 +181,7 @@ export default class VocabService {
vocabTrainerCurrentAttempts: this._clampInteger(value.vocabTrainerCurrentAttempts, { max: 10000 }),
vocabTrainerReviewAttempts: this._clampInteger(value.vocabTrainerReviewAttempts, { max: 10000 }),
vocabTrainerStats: this._sanitizeVocabTrainerStats(value.vocabTrainerStats),
vocabTrainerRepeatQueue: this._sanitizeRepeatQueue(value.vocabTrainerRepeatQueue),
exerciseAnswers: this._sanitizeExerciseAnswers(value.exerciseAnswers),
exerciseResults: this._sanitizeExerciseResults(value.exerciseResults),
exerciseRetryPending: Boolean(value.exerciseRetryPending),