Fix scope bug that dropped the referral from the join button
The placement flag was declared inside the invited-visitor branch but read further down when building the join button href, so it threw a ReferenceError there. The display was right — the page named the inviter correctly — but the button fell back to a bare /join-now, which is the one place that actually matters. Caught by walking the live paths rather than trusting the earlier pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+12
-4
@@ -13,9 +13,21 @@ function invitedBy(){
|
|||||||
}catch(e){}
|
}catch(e){}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
function placementChoice(){
|
||||||
|
try{
|
||||||
|
const q=new URLSearchParams(location.search).get('direct');
|
||||||
|
if(q==='1'||q==='0')return q;
|
||||||
|
const m=document.cookie.match(/(?:^|;\s*)rmc_direct=([01])/);
|
||||||
|
if(m)return m[1];
|
||||||
|
}catch(e){}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
async function load(){
|
async function load(){
|
||||||
try{
|
try{
|
||||||
const ref=invitedBy();
|
const ref=invitedBy();
|
||||||
|
// an explicit ?direct=1/0 from the invite link wins over the position's default, and it
|
||||||
|
// has to be in scope for the join button further down — not just the display block
|
||||||
|
const dq=placementChoice();
|
||||||
const [cr,sr]=await Promise.all([
|
const [cr,sr]=await Promise.all([
|
||||||
fetch('/api/public/config'),
|
fetch('/api/public/config'),
|
||||||
fetch(ref?('/api/public/member?id='+encodeURIComponent(ref)):'/api/public/current-sponsor')
|
fetch(ref?('/api/public/member?id='+encodeURIComponent(ref)):'/api/public/current-sponsor')
|
||||||
@@ -26,10 +38,6 @@ async function load(){
|
|||||||
// Route exactly the way that member's own invite page would: their moving link sends
|
// Route exactly the way that member's own invite page would: their moving link sends
|
||||||
// the join to the next position in their leg, unless their position is set to take
|
// the join to the next position in their leg, unless their position is set to take
|
||||||
// direct placements. Same rules, so the two pages can never disagree.
|
// direct placements. Same rules, so the two pages can never disagree.
|
||||||
// an explicit ?direct=1/0 from the invite link wins over the position's default
|
|
||||||
const dq=(function(){try{const q=new URLSearchParams(location.search).get('direct');
|
|
||||||
if(q==='1'||q==='0')return q;
|
|
||||||
const m=document.cookie.match(/(?:^|;\s*)rmc_direct=([01])/);return m?m[1]:null;}catch(e){return null}})();
|
|
||||||
const goDirect=dq==='1'||(dq!=='0'&&(s.directDefault||!s.joinTarget));
|
const goDirect=dq==='1'||(dq!=='0'&&(s.directDefault||!s.joinTarget));
|
||||||
const t=goDirect?{id:s.id,referralUrl:s.referralUrl,directCount:s.directCount}:s.joinTarget;
|
const t=goDirect?{id:s.id,referralUrl:s.referralUrl,directCount:s.directCount}:s.joinTarget;
|
||||||
currentSponsor={id:t.id,name:null,directs:(t.directCount!==undefined?t.directCount:0),goal:2,referralUrl:t.referralUrl};
|
currentSponsor={id:t.id,name:null,directs:(t.directCount!==undefined?t.directCount:0),goal:2,referralUrl:t.referralUrl};
|
||||||
|
|||||||
Reference in New Issue
Block a user