diff options
| author | 2020-10-06 18:59:58 +0100 | |
|---|---|---|
| committer | 2020-10-06 18:59:58 +0100 | |
| commit | ccbc5e620adf05cbf6e89bd20874721f11821d1e (patch) | |
| tree | 72eca2c8625dd4cf573d31f8bac6e5d8636ce4cb /src | |
| parent | Merge pull request #19 from python-discord/discord/add-oauth2-authorize (diff) | |
Add a setInterval to check if the child window is manually closed
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/OAuth2Button.tsx | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/src/components/OAuth2Button.tsx b/src/components/OAuth2Button.tsx index 1b3d588..08c4b7f 100644 --- a/src/components/OAuth2Button.tsx +++ b/src/components/OAuth2Button.tsx @@ -50,6 +50,13 @@ function doLogin(disableFunction: (newState: boolean) => void) {      "height=700,width=500,location=no,menubar=no,resizable=no,status=no,titlebar=no,left=300,top=300"    ) +  const interval = setInterval(() => { +    if (windowRef?.closed) { +      clearInterval(interval); +      disableFunction(false); +    } +  }, 500) +    window.onmessage = (code: MessageEvent) => {      if (code.data.hello) {        // React DevTools has a habit of sending messages, ignore them. @@ -62,6 +69,7 @@ function doLogin(disableFunction: (newState: boolean) => void) {        console.log("Code received:", code.data);        disableFunction(false); +      clearInterval(interval);        window.onmessage = null;      } | 
