It’s only possible to provide a single block of code, but you can make it behave differently depending on the deck using a bit of a hack: if you add <div id=deck>{{Deck}}</div> to the card template, your custom scheduling code can extract the deck name from the DOM, and vary its behaviour as necessary.
Sometime, the card’s render is slower than review.js. so the custom scheduling couldn’t get the deck name correctly. Someone reports it to me:
opened 06:38AM - 28 Feb 23 UTC
closed 04:07AM - 11 Apr 23 UTC
bug
**Describe the bug**
At random, cards appear as "Deck name not found" when disp… lay_memory_state is set to true. Usually it happens on the first card of the deck, or if I study on a parent deck and anki jumps between the children decks, but it's not a rule. The deck is set up properly in the config, the proper div object is also present in the card.
It looks like a race condition, when FSRS4Anki loads before the card finishes loading. It might be a bug in Anki itself. I see there was an [attempt](https://github.com/open-spaced-repetition/fsrs4anki/commit/4c480405d7bb9416b9dfa49d418bb75a045f3ce2) to make it wait for the card to render, but it has been reverted.
**Environment**
- Anki version: 2.1.60 QT6
- OS: Linux (Arch)
- Scheduler version: v3.14.3
**Screenshoots**

After going back to main screen and back to study

The position of the div doesn't seem to matter. I've had it on top of the card and the issue was also present.
Is it possible to block the review.js until the card’s front is rendered?
1 Like
I have attempt to use some async method to solve it:
function wait_card_front() {
return new Promise(resolve => {
if (document.getElementById("qa").textContent != "") {
return resolve(document.getElementById("qa").textContent);
}
const observer = new MutationObserver(mutations => {
if (document.getElementById("qa").textContent != "") {
resolve(document.getElementById("qa").textContent);
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
But the mutator is not async:
export async function mutateNextCardStates(
key: string,
mutator: (states: Scheduler.SchedulingStates, customData: CustomDataStates) => void,
): Promise<void> {
const states = await getSchedulingStates();
const customData = unpackCustomData(states);
mutator(states, customData);
packCustomData(states, customData);
await setSchedulingStates(key, states);
}
So the states and customData aren’t modified when I use async method in the custom scheduling.
A related issue:
opened 04:25PM - 21 Feb 23 UTC
closed 11:20AM - 26 Feb 23 UTC
bug
**Describe the bug**
If I click "Show Answer" while reviewing a card, then go b… ack to "Decks", then review the card again, I get different intervals. I don't think this was a problem before 2.1.58, or maybe I just didn't notice.
EDIT: I reverted back to 2.1.54 and yes, it works properly.
EDIT 2: nevermind, it doesn't work on 2.1.54, now I'm just really confused

EDIT 3: ok, I deleted all Anki files and did a fresh installation of 2.1.55 (not 2.1.54) and I _think_ it works fine.
EDIT 4: I give up, I don't know what the hell is going on. Maybe after many re-installations I messed something up so bad that now every re-installation is broken.

**To Reproduce**
Steps to reproduce the behavior:
1. Review a card and click "Show Answer"
2. Don't click on answer buttons and click on "Decks" instead to cancel the review
3. Review that card again
4. See that intervals are different
**Expected behavior**
Intervals shouldn't change if I cancel a review and review again.
**Screenshots**

**Environment**
- Anki version: 2.1.58, Qt 6.4.2, PyQt 6.4.0
- OS: Windows 10
- Scheduler version: v3.13.4
Sometime the intervals above rating buttons are inconsistent with the intervals given by custom scheduling. After pressing the button and checking the previous card’s info, the recorded interval is the one given by custom scheduling instead of the one above the button. Maybe it is caused by the async problem, too.
dae
March 1, 2023, 7:09am
4
1 Like