mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-27 00:55:16 -07:00
fix: refresh current subtitle after known-word mining
This commit is contained in:
+21
-1
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user