I hope this is the right place to put this. Sorry if it isn’t
Found a bug with the custom scheduler.
If you end your code with a (//) comment you get
1097:3 Uncaught SyntaxError: Unexpected token ‘.’
Looking at the inspector, looks like the custom code doesn’t get put in the code block properly.
anki.mutateNextCardStates('17644981876544821410', async (states, customData, ctx) => { //console.log(JSON.stringify(states, null, 4)); })
.finally(() => bridgeCommand('statesMutated'));
Note the closing }) is inside the comment
My custom schedule code
//console.log(JSON.stringify(states, null, 4));
With nothing else
If you add a newline at the end it does make the error disappear
Version 24.11 (87ccd24e)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Windows 10
1 Like
I can reproduce with
Anki 25.01 (3364daa0) (src)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Linux-6.12.6-amd64-x86_64-with-glibc2.40
Steps to reproduce
anki --safemode
- Open deck options.
- Add only some comment into custom scheduler in advanced (like
//console.log(JSON.stringify(states, null, 4));
)
- Terminal prints
JS error /_anki/legacyPageData?id=140476106741792:3 Uncaught SyntaxError: Unexpected token '.'
The call that op states comes from qt/aqt/reviewer.py
line 1219:
RUN_STATE_MUTATION = """
anki.mutateNextCardStates('{key}', async (states, customData, ctx) => {{ {js} }})
.finally(() => bridgeCommand('statesMutated'));
"""
I opened a PR to fix this:
2 Likes
llama
4
Changing that to the following should be an easy fix
RUN_STATE_MUTATION = """
anki.mutateNextCardStates('{key}', async (states, customData, ctx) => {{
{js}
}}).finally(() => bridgeCommand('statesMutated'));
"""
1 Like
I guess this is better than my fix above since your version doesn’t need custom code logic.
I’ll edit my PR accordingly.
system
Closed
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.