Load GSI client dynamically from app.js

This commit is contained in:
Ian Gulliver
2025-12-29 12:48:33 -08:00
parent 4e4bb49e8c
commit 39d88019e8
2 changed files with 7 additions and 16 deletions

View File

@@ -26,20 +26,12 @@ function bind(data) {
});
}
function waitForGoogle() {
return new Promise((resolve) => {
if (typeof google !== 'undefined') {
resolve();
return;
}
const check = setInterval(() => {
if (typeof google !== 'undefined') {
clearInterval(check);
resolve();
}
}, 50);
});
}
const googleReady = new Promise((resolve) => {
const script = document.createElement('script');
script.src = 'https://accounts.google.com/gsi/client';
script.onload = resolve;
document.head.appendChild(script);
});
export async function auth() {
let profile = getProfile();
@@ -48,7 +40,7 @@ export async function auth() {
return profile;
}
await waitForGoogle();
await googleReady;
const signin = document.getElementById('signin');
signin.style.display = 'block';

View File

@@ -7,7 +7,6 @@
<title>HCA Tickets</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist-cdn/styles/themes/default.css">
<script type="module" src="https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist-cdn/webawesome.loader.js"></script>
<script src="https://accounts.google.com/gsi/client" async></script>
<style>
body {
font-family: var(--wa-font-sans);