Skip to content

Commit

Permalink
Update redirect link vs forward search params
Browse files Browse the repository at this point in the history
  • Loading branch information
saltict committed Jun 7, 2024
1 parent 8d20d1b commit 7ddbc37
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/templates/webapp.pug
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ html(lang="en")

body(style="background-color: rgb(12, 12, 12);")
div#root
a(href=url)
a#redirect-link(href=url)
div#loading-placeholder(style="background-color: rgb(12, 12, 12); position:fixed; top: 0; left: 0; right: 0; bottom: 0")
img#loading-img(src="https://web.subwallet.app/images/loading.svg", style="position: absolute; top: calc(50% - 50px); left: calc(50% - 50px)", alt="Loading")
script.
Expand All @@ -43,10 +43,14 @@ html(lang="en")
});
}

var queryString = window.location.search;
var finalUrl = '#{url}' + queryString;
var inSubWallet = detectMob() && window.SubWallet;
var isTelegramLink = '#{url}'.startsWith('https://t.me');
var fallback_image = !{JSON.stringify(fallback_image)};

document.getElementById('redirect-link').href = finalUrl;

if (inSubWallet && isTelegramLink && fallback_image) {
// replace img in loading-placeholder > img
var img = document.getElementById('loading-img');
Expand All @@ -62,9 +66,6 @@ html(lang="en")
}
else {
window.addEventListener('load', function() {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const startApp = urlParams.get('startApp');
window.location.replace('#{url}' + (startApp ? '?startApp=' + startApp : ''));
window.location.replace(finalUrl);
})
}

0 comments on commit 7ddbc37

Please sign in to comment.