fix: refresh current subtitle after known-word mining

This commit is contained in:
2026-05-02 20:56:59 -07:00
parent ce3ab0842a
commit 45193e4c97
6 changed files with 137 additions and 8 deletions
+21 -1
View File
@@ -148,6 +148,7 @@ export class AnkiIntegration {
private runtime: AnkiIntegrationRuntime;
private aiConfig: AiConfig;
private recordCardsMinedCallback: ((count: number, noteIds?: number[]) => void) | null = null;
private knownWordCacheUpdatedCallback: (() => void) | null = null;
private noteIdRedirects = new Map<number, number>();
private trackedDuplicateNoteIds = new Map<number, number[]>();
@@ -552,10 +553,25 @@ export class AnkiIntegration {
return;
}
this.knownWordCache.appendFromNoteInfo({
const changed = this.knownWordCache.appendFromNoteInfo({
noteId: noteInfo.noteId,
fields: noteInfo.fields,
});
if (changed) {
this.notifyKnownWordCacheUpdated();
}
}
private notifyKnownWordCacheUpdated(): void {
if (!this.knownWordCacheUpdatedCallback) {
return;
}
try {
this.knownWordCacheUpdatedCallback();
} catch (error) {
log.warn('Known-word cache update callback failed:', (error as Error).message);
}
}
private getLapisConfig(): {
@@ -1267,6 +1283,10 @@ export class AnkiIntegration {
this.recordCardsMinedCallback = callback;
}
setKnownWordCacheUpdatedCallback(callback: (() => void) | null): void {
this.knownWordCacheUpdatedCallback = callback;
}
resolveCurrentNoteId(noteId: number): number {
let resolved = noteId;
const seen = new Set<number>();