fix app invite share link code
This commit is contained in:
parent
c27a8acd8f
commit
f80bb2481a
@ -580,8 +580,39 @@ function formatSignedReward(value) {
|
|||||||
return `+${formatMetric(raw)}`;
|
return `+${formatMetric(raw)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildInviteShareURL(inviteLink, inviteCode) {
|
||||||
|
const rawURL = trimValue(inviteLink);
|
||||||
|
const code = trimValue(inviteCode);
|
||||||
|
if (!rawURL || !code) {
|
||||||
|
return rawURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = new URL(rawURL, window.location.href);
|
||||||
|
if (url.hostname.includes("play.google.com")) {
|
||||||
|
const referrer = new URLSearchParams(url.searchParams.get("referrer") || "");
|
||||||
|
setPlayInstallReferrer(referrer, code);
|
||||||
|
removeTopLevelInviteCodeParams(url.searchParams);
|
||||||
|
url.searchParams.set("referrer", referrer.toString());
|
||||||
|
return url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
setInviteCodeParams(url.searchParams, code);
|
||||||
|
return url.toString();
|
||||||
|
} catch {
|
||||||
|
const separator = rawURL.includes("?") ? "&" : "?";
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
setInviteCodeParams(params, code);
|
||||||
|
return `${rawURL}${separator}${params.toString()}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function currentInviteShareURL() {
|
||||||
|
return buildInviteShareURL(state.inviteLink, state.inviteCode);
|
||||||
|
}
|
||||||
|
|
||||||
function renderStats() {
|
function renderStats() {
|
||||||
els.inviteLinkText.textContent = trimValue(state.inviteLink) || "--";
|
els.inviteLinkText.textContent = trimValue(currentInviteShareURL()) || "--";
|
||||||
els.inviteCodeText.textContent = trimValue(state.inviteCode) || "--";
|
els.inviteCodeText.textContent = trimValue(state.inviteCode) || "--";
|
||||||
els.statInvitees.textContent = formatMetric(state.invitees);
|
els.statInvitees.textContent = formatMetric(state.invitees);
|
||||||
els.statEligible.textContent = formatMetric(state.eligibleVoters);
|
els.statEligible.textContent = formatMetric(state.eligibleVoters);
|
||||||
@ -1131,7 +1162,7 @@ function bindEvents() {
|
|||||||
els.copyButtons.forEach((button) => {
|
els.copyButtons.forEach((button) => {
|
||||||
button.addEventListener("click", async () => {
|
button.addEventListener("click", async () => {
|
||||||
const target = button.getAttribute("data-copy-target");
|
const target = button.getAttribute("data-copy-target");
|
||||||
const value = target === "invite-code" ? state.inviteCode : state.inviteLink;
|
const value = target === "invite-code" ? state.inviteCode : currentInviteShareURL();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await copyText(trimValue(value));
|
await copyText(trimValue(value));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user