From 8c1332c0c6defcba3b6574baebe30ea53e915119 Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Sat, 6 Jun 2026 10:29:27 +0000 Subject: [PATCH] Fix platform grid not showing for logged-in regular users Two issues: 1. Race condition: me.php resolves before the platforms fetch, so showApp() runs with an empty CFG.platforms and the grid stays blank until the Promise.all resolves. Fixed by calling buildPlatforms() inside showApp() when platforms are already loaded, guaranteeing the grid renders when the app becomes visible. 2. Stale placeholder: 'links' platform (is_active=1) was polluting the grid with a "Platform Links coming..." card. Disabled in DB (is_active=0). Also hardened buildPlatforms/buildCashoutPlatforms: null-guard on selects, early return when CFG.platforms is empty, and clear select options before re-populating to prevent duplicates on re-call. Co-Authored-By: Claude Sonnet 4.6 --- index.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) 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); });