Skip to content

Commit

Permalink
Fix infinite login awaiting
Browse files Browse the repository at this point in the history
  • Loading branch information
disturm committed Jun 9, 2021
1 parent 40bd6ef commit 364d84d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/apis/GoogleAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ const SCOPES = "profile email https://www.googleapis.com/auth/spreadsheets";
export default class GoogleAuth {
async ensureInitializedAsync() {
if (gapi.client) return;
return new Promise<void>((resolve) => {
gapi.load("client:auth2", async () => {
await gapi.client
.init({
clientId: CLIENT_ID,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES,
})
.catch(console.error);
resolve();
});

await new Promise<void>((resolve) => {
gapi.load("client:auth2", resolve);
});

// NOTE: выполнение init не надо ждать
gapi.client
.init({
clientId: CLIENT_ID,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES,
})
.catch(console.error);
}

checkAuthorized() {
Expand Down

0 comments on commit 364d84d

Please sign in to comment.