mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-27 04:49:49 -07:00
fix(anki): keep existing maturity tier on re-mined notes
- appendFromNoteInfo no longer overwrites a note's tracked tier with 'new' when the note already has one recorded - add test covering re-mining a note that already has a mature/learning tier
This commit is contained in:
@@ -342,3 +342,33 @@ test('appendFromNoteInfo marks freshly mined notes as new tier', async () => {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('appendFromNoteInfo preserves an existing maturity tier', async () => {
|
||||
const { manager, clientState, cleanup } = createMaturityHarness(maturityConfig());
|
||||
|
||||
try {
|
||||
clientState.findNotesByQuery.set('deck:"Mining"', [7, 8]);
|
||||
clientState.findNotesByQuery.set('deck:"Mining" prop:ivl>=21', [7]);
|
||||
clientState.findNotesByQuery.set('deck:"Mining" prop:ivl>=1 prop:ivl<21', []);
|
||||
clientState.findNotesByQuery.set('deck:"Mining" is:learn', [8]);
|
||||
clientState.notesInfoResult = [
|
||||
{ noteId: 7, fields: { Word: { value: '猫' } } },
|
||||
{ noteId: 8, fields: { Word: { value: '犬' } } },
|
||||
];
|
||||
await manager.refresh(true);
|
||||
|
||||
manager.appendFromNoteInfo({
|
||||
noteId: 7,
|
||||
fields: { Word: { value: '子猫' } },
|
||||
});
|
||||
manager.appendFromNoteInfo({
|
||||
noteId: 8,
|
||||
fields: { Word: { value: '子犬' } },
|
||||
});
|
||||
|
||||
assert.equal(manager.getKnownWordTier('子猫'), 'mature');
|
||||
assert.equal(manager.getKnownWordTier('子犬'), 'learning');
|
||||
} finally {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -342,7 +342,11 @@ export class KnownWordCacheManager {
|
||||
}
|
||||
|
||||
// A just-mined card has never been reviewed.
|
||||
if (this.isMaturityTrackingEnabled() && this.noteEntriesById.has(noteInfo.noteId)) {
|
||||
if (
|
||||
this.isMaturityTrackingEnabled() &&
|
||||
this.noteEntriesById.has(noteInfo.noteId) &&
|
||||
!this.noteTierById.has(noteInfo.noteId)
|
||||
) {
|
||||
this.noteTierById.set(noteInfo.noteId, 'new');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user