fix(srs): retain scheduled cards after course updates

This commit is contained in:
Torsten Schulz (local)
2026-08-31 12:48:33 +02:00
parent 7ad83f4299
commit 0119048c82

View File

@@ -2060,22 +2060,19 @@ export default class VocabService {
['stage', 'ASC'] ['stage', 'ASC']
] ]
}); });
const validPool = await this.getCompletedLessonVocabPool(hashedUserId, course.id); // Do not require a scheduled card to be present verbatim in today's
const validPairs = new Set( // regenerated lesson pool. Course content can be corrected after a card
(Array.isArray(validPool?.vocabs) ? validPool.vocabs : []) // has been scheduled; comparing against the regenerated pool then hid all
.map((entry) => this._buildSrsPairFingerprint(entry)) // legitimate older SRS cards. `_isTrainableSrsPair` above remains the
.filter(Boolean) // content-level guard for malformed fragments, hints and task prompts.
);
const validDueRows = scheduledRows.filter((item) => const validDueRows = scheduledRows.filter((item) =>
this._isTrainableSrsPair(item) this._isTrainableSrsPair(item)
&& (!validPairs.size || validPairs.has(this._buildSrsPairFingerprint(item)))
&& this._getSrsScheduleDateKey(item.nextDueAt) <= todayKey && this._getSrsScheduleDateKey(item.nextDueAt) <= todayKey
); );
const upcomingByDate = new Map(); const upcomingByDate = new Map();
scheduledRows scheduledRows
.filter((item) => ( .filter((item) => (
this._isTrainableSrsPair(item) this._isTrainableSrsPair(item)
&& (!validPairs.size || validPairs.has(this._buildSrsPairFingerprint(item)))
&& this._getSrsScheduleDateKey(item.nextDueAt) > todayKey && this._getSrsScheduleDateKey(item.nextDueAt) > todayKey
)) ))
.forEach((item) => { .forEach((item) => {