mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Preserve initial note load args
This commit is contained in:
parent
224ea3abb1
commit
5e9428cd26
1 changed files with 10 additions and 23 deletions
|
|
@ -102,6 +102,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
import { CooldownTimer } from "$lib/editable/cooldown-timer";
|
||||
|
||||
const loadDebouncer = new CooldownTimer(200);
|
||||
let initialLoadArgs: Partial<LoadNoteArgs> | null = null;
|
||||
let contextMenu: ContextMenu;
|
||||
const [onContextMenu, contextMenuItems] = setupContextMenu();
|
||||
let contextMenuInput: EditingInputAPI | null = null;
|
||||
|
|
@ -1175,34 +1176,20 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
triggerChanges();
|
||||
}
|
||||
|
||||
async function loadNote({
|
||||
nid = note?.id,
|
||||
notetypeId = notetypeMeta ? notetypeMeta.id : null,
|
||||
deckId = null,
|
||||
focusTo = focusedFieldIndex,
|
||||
originalNoteId = null,
|
||||
reviewerCardId = reviewerCard ? reviewerCard.id : null,
|
||||
initial = false,
|
||||
copyFromNote = null,
|
||||
stickyFieldsFrom = null,
|
||||
}: Partial<LoadNoteArgs> = {}) {
|
||||
async function loadNote(args: Partial<LoadNoteArgs>) {
|
||||
if(args.initial) {
|
||||
initialLoadArgs = args;
|
||||
}
|
||||
loadDebouncer.schedule(async () => {
|
||||
await loadNoteInner({
|
||||
nid,
|
||||
notetypeId,
|
||||
deckId,
|
||||
focusTo,
|
||||
originalNoteId,
|
||||
reviewerCardId,
|
||||
initial,
|
||||
copyFromNote,
|
||||
stickyFieldsFrom,
|
||||
});
|
||||
await loadNoteInner(initialLoadArgs ? {
|
||||
...initialLoadArgs,
|
||||
...args,
|
||||
} as LoadNoteArgs : args as LoadNoteArgs);
|
||||
});
|
||||
}
|
||||
|
||||
async function reloadNote() {
|
||||
await loadNote();
|
||||
await loadNote(initialLoadArgs!);
|
||||
}
|
||||
|
||||
async function reloadNoteIfEmpty(deckId: bigint | null, notetypeId: bigint | null) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue