Fix stale dashboard right after own tx: fresh=1 cache bypass (one-shot via sessionStorage flag) set on upgrade success and post-join redirect

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-19 15:36:08 -05:00
parent 70fc321c3e
commit 0754a858c3
3 changed files with 11 additions and 4 deletions
+1
View File
@@ -147,6 +147,7 @@
$('resultLink').href='/my/'+newId; $('resultLink').style.display='inline-flex';
log('🎉 Confirmed — your position is <strong>#'+newId+'</strong>. Redirecting to your dashboard…','ok');
try{ el_scroll('result'); }catch(e){}
try{sessionStorage.setItem('rmc.fresh','1');}catch(e){}
setTimeout(function(){ location.href='/my/'+newId; }, 4500);
} else {
log('Confirmed on-chain. Open your dashboard at <a href="/my">/my</a> and enter your new ID (also shown on Polygonscan).','ok');
+5 -2
View File
@@ -221,7 +221,7 @@
for(let i=0;i<60;i++){
try{const rc=await upEth.request({method:'eth_getTransactionReceipt',params:[tx]});
if(rc){if(rc.status==='0x0'){upgLog('⚠️ The upgrade reverted — your POL was returned (minus gas). Wait a moment and try again.',true);return;}
upgLog('🎉 <strong>Upgraded!</strong> Refreshing your dashboard…');setTimeout(function(){location.reload();},2500);return;}
upgLog('🎉 <strong>Upgraded!</strong> Refreshing your dashboard…');try{sessionStorage.setItem('rmc.fresh','1');}catch(e){}setTimeout(function(){location.reload();},3000);return;}
}catch(e){}
await new Promise(function(s){setTimeout(s,3000);});
}
@@ -481,7 +481,10 @@
}
async function load(id){
try{
const r=await fetch('/api/public/member?id='+id);
// after our own join/upgrade tx, force one cache-bypassing read so the
// dashboard reflects the transaction immediately instead of the cache
let fresh='';try{if(sessionStorage.getItem('rmc.fresh')){fresh='&fresh=1&_t='+Date.now();sessionStorage.removeItem('rmc.fresh');}}catch(e){}
const r=await fetch('/api/public/member?id='+id+fresh);
const d=await r.json();
if(!r.ok)throw new Error(d.error||'Lookup failed');
if(!d.registered)throw new Error(`ID ${id} isn't registered on the smart contract — double-check the number.`);