Admin: load the bonus panel after login, not before

The panel fetched its tool list on DOMContentLoaded — which fires while the
admin page is still showing the login form. The request 401'd, the handler
returned silently, and the "What" select was left permanently empty with no
path back.

Loads from the same post-login block as the coaching radar and messages
panels now, plus a refetch if the select is opened while still empty.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-30 05:51:26 -05:00
parent 05afe5c5f6
commit e4b7d64605
2 changed files with 8 additions and 1 deletions
+6 -1
View File
@@ -78,7 +78,12 @@
}catch(e){ msg.style.color='#f0a05a'; msg.textContent='Connection hiccup.'; }
$('agGo').disabled=false;
}
document.addEventListener('DOMContentLoaded',function(){ boot(); var b=$('agGo'); if(b) b.addEventListener('click',award); });
window.agBoot=boot;
document.addEventListener('DOMContentLoaded',function(){
var b=$('agGo'); if(b) b.addEventListener('click',award);
// Belt and braces: if the select is still empty when it's opened, try again.
var sel=$('agTool'); if(sel) sel.addEventListener('focus',function(){ if(!sel.options.length) boot(); });
});
})();
</script>
</body></html>
+2
View File
@@ -43,6 +43,7 @@ function render(){
const orgEl=document.getElementById('orgRoot');if(orgEl&&!orgEl.value)orgEl.value=state.config.orgRootId||'21';
if(!orgShareAutoLoaded&&orgEl&&orgEl.value){orgShareAutoLoaded=true;loadOrgShare();}
if(!coachAutoLoaded){coachAutoLoaded=true;loadCoaching();}
if(!grantAutoLoaded){grantAutoLoaded=true;if(window.agBoot)window.agBoot();}
if(!msgsAutoLoaded){msgsAutoLoaded=true;loadAdminMsgs();}
const efi=document.getElementById('emailFromInput');if(efi&&!efi.value)efi.value=state.config.emailFrom||em.from||'';
const f=document.getElementById('configForm'),c=state.config;for(const k of ['siteName','programName','bridgeHeadline','bridgeSubheadline','premiumEntryPol','dappReferralBaseUrl','telegramUrl','supportLabel','bemobPostbackUrl','telegramBotToken','telegramChatId','telegramTopicId','teamRootId','teamAlertEmail','ownerAlertEmail'])if(f.elements[k])f.elements[k].value=c[k]??'';f.elements.showSponsorName.checked=!!c.showSponsorName;f.elements.showQueueProgress.checked=!!c.showQueueProgress;
@@ -124,6 +125,7 @@ async function loadCoaching(){
}
const cr=document.getElementById('coachRefresh');if(cr)cr.addEventListener('click',loadCoaching);
let coachAutoLoaded=false;
let grantAutoLoaded=false;
async function loadAdminMsgs(){
const tb=document.getElementById('msgRows');if(!tb)return;
try{