diff --git a/index.php b/index.php index 11eaab6..811a6d3 100644 --- a/index.php +++ b/index.php @@ -1317,7 +1317,10 @@ function showApp() { var app = document.getElementById('main-app'); if (auth) auth.setAttribute('style', 'display:none'); if (app) app.setAttribute('style', 'display:block;min-height:100vh;'); - console.log('showApp: auth hidden, app visible'); + // Rebuild platform grid now that app is visible (covers race where me.php resolves before platforms fetch) + if (CFG.platforms && CFG.platforms.length) { + try { buildPlatforms(); buildCashoutPlatforms(); } catch(e) {} + } try { updateUI(); } catch(e) { console.warn('updateUI err:', e); } try { loadCashoutHistory(); } catch(e) { console.warn('cashout err:', e); } try { pollChatBadge(); } catch(e) { console.warn('badge err:', e); } @@ -1398,7 +1401,11 @@ async function refreshUser() { // ─── PLATFORMS ───────────────────────────────────────────── function buildPlatforms() { - document.getElementById('platform-grid').innerHTML = CFG.platforms.map(p => ` + if (!CFG.platforms || !CFG.platforms.length) return; + + const grid = document.getElementById('platform-grid'); + if (grid) { + grid.innerHTML = CFG.platforms.map(p => `
${p.name} @@ -1406,16 +1413,22 @@ function buildPlatforms() {
${p.name}
TAP TO PLAY →
`).join(''); + } - // Also populate buy-platform select - const sel = document.getElementById('buy-platform'); - CFG.platforms.forEach(p => { - const o = document.createElement('option'); - o.value = p.id; o.textContent = p.name; sel.appendChild(o); - }); + // Populate selects — clear dynamic options first to prevent duplicates on re-call + const buySel = document.getElementById('buy-platform'); + if (buySel) { + while (buySel.options.length > 1) buySel.remove(1); + CFG.platforms.forEach(p => { + const o = document.createElement('option'); + o.value = p.id; o.textContent = p.name; buySel.appendChild(o); + }); + } } function buildCashoutPlatforms() { const sel = document.getElementById('cashout-platform'); + if (!sel) return; + while (sel.options.length > 1) sel.remove(1); CFG.platforms.forEach(p => { const o = document.createElement('option'); o.value = p.id; o.textContent = p.name; sel.appendChild(o); });