mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 06:00:46 -05:00
fix: do not animate non-existing captcha modal
Calling `.fadeOut()` on the result of a jquery selector (i.e. the
evaluation of `$('.some-element-class')`, when it returns an object with
`length=0`) is a NOOP. That's right, it doesn't throw an error; it just
does nothing. This was preventing a temporary user from being created
when `.captcha-modal` isn't present because [the code intended to execute
after the animation] was never run. (square brackets for clarity because
the English is inherently ambiguous)
This commit is contained in:
+19
-16
@@ -991,24 +991,27 @@ window.initgui = async function(options){
|
||||
data: JSON.stringify(requestData),
|
||||
success: async function (data){
|
||||
setTimeout(() => {
|
||||
$('.captcha-modal').fadeOut(200, function(){
|
||||
$(this).remove();
|
||||
const fn = function(){
|
||||
$(this).remove();
|
||||
|
||||
// if this is a popup, hide the spinner, make sure it was visible for at least 2 seconds
|
||||
if(window.embedded_in_popup){
|
||||
let spinner_duration = (Date.now() - spinner_init_ts);
|
||||
setTimeout(() => {
|
||||
// if this is a popup, hide the spinner, make sure it was visible for at least 2 seconds
|
||||
if(window.embedded_in_popup){
|
||||
let spinner_duration = (Date.now() - spinner_init_ts);
|
||||
setTimeout(() => {
|
||||
window.update_auth_data(data.token, data.user);
|
||||
document.dispatchEvent(new Event("login", { bubbles: true}));
|
||||
puter.ui.hideSpinner();
|
||||
}, spinner_duration > 2000 ? 10 : 2000 - spinner_duration);
|
||||
|
||||
return;
|
||||
}else{
|
||||
window.update_auth_data(data.token, data.user);
|
||||
document.dispatchEvent(new Event("login", { bubbles: true}));
|
||||
puter.ui.hideSpinner();
|
||||
}, spinner_duration > 2000 ? 10 : 2000 - spinner_duration);
|
||||
|
||||
return;
|
||||
}else{
|
||||
window.update_auth_data(data.token, data.user);
|
||||
document.dispatchEvent(new Event("login", { bubbles: true}));
|
||||
}
|
||||
});
|
||||
document.dispatchEvent(new Event("login", { bubbles: true}));
|
||||
}
|
||||
};
|
||||
|
||||
if ( ! $('.captcha-modal')?.length ) fn();
|
||||
else $('.captcha-modal').fadeOut(200, fn);
|
||||
}, (Date.now() - window.turnstile_success_ts) > 2000 ? 10 : 2000 - (Date.now() - window.turnstile_success_ts));
|
||||
},
|
||||
error: async (err) => {
|
||||
|
||||
Reference in New Issue
Block a user