Load GSI client dynamically from app.js
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user