Hey there,
I'm trying to get past the use of the use of M.util.set_user_preference() through javascript but i'm getting an error wich i can't wrap my head around.
Up until now i used the function like this :
M.util.set_user_preference('theme_celene4boost_mode', 'dark');
Which, up to moodle 4.1 worked fine.
So, in my attempt to update it, i declare my function likewise :
//on top of the script
import {setUserPreference} from 'core_user/repository';
//inside my function
setUserPreference('theme_celene4boost_mode', 'dark');
The function is recognized but, for some strange reason it always results into this error in console : Uncaught (in promise) Error: Invalid parameter value detected (Invalid preference 'theme_celene4boost_mode')
The rest of the script works like a charm and the error ain't blocking anything, but i can't save the user preference none the less.
I get the feeling the error should be self explanatory in itself but i can't seem to understand. Since it's a preference and since it's not supposed to already exists, it shouldn't be a problem. The only thing i may think is that i pass a string for both the parameters... But if not that, what type should i pass?
I'd love to have an opinion, (and revere anyone who could come up with an explanation slash solution ^^), on this matter.