diff --git a/fission/src/Synthesis.tsx b/fission/src/Synthesis.tsx index 2cdba8456d..51e9c4db05 100644 --- a/fission/src/Synthesis.tsx +++ b/fission/src/Synthesis.tsx @@ -47,7 +47,6 @@ import ManageAssembliesModal from "@/modals/spawning/ManageAssembliesModal.tsx" import World from "@/systems/World.ts" import { AddRobotsModal, AddFieldsModal, SpawningModal } from "@/modals/spawning/SpawningModals.tsx" import ImportLocalMirabufModal from "@/modals/mirabuf/ImportLocalMirabufModal.tsx" -import APS from "./aps/APS.ts" import ImportMirabufPanel from "@/ui/panels/mirabuf/ImportMirabufPanel.tsx" import Skybox from "./ui/components/Skybox.tsx" import ChooseInputSchemePanel from "./ui/panels/configuring/ChooseInputSchemePanel.tsx" @@ -71,18 +70,6 @@ import PreferencesSystem from "./systems/preferences/PreferencesSystem.ts" const worker = new Lazy(() => new WPILibWSWorker()) function Synthesis() { - const urlParams = new URLSearchParams(document.location.search) - const has_code = urlParams.has("code") - useEffect(() => { - if (has_code) { - const code = urlParams.get("code") - if (code) { - APS.convertAuthToken(code).then(() => { - document.location.search = "" - }) - } - } - }, []) const { openModal, closeModal, getActiveModalElement } = useModalManager(initialModals) const { openPanel, closePanel, closeAllPanels, getActivePanelElements } = usePanelManager(initialPanels) const { showTooltip } = useTooltipManager() @@ -99,7 +86,12 @@ function Synthesis() { const modalElement = getActiveModalElement() useEffect(() => { - if (has_code) return + const urlParams = new URLSearchParams(document.location.search) + if (urlParams.has("code")) { + window.opener.convertAuthToken(urlParams.get("code")) + window.close() + return + } World.InitWorld() diff --git a/fission/src/Window.d.ts b/fission/src/Window.d.ts new file mode 100644 index 0000000000..2e476b33b7 --- /dev/null +++ b/fission/src/Window.d.ts @@ -0,0 +1,3 @@ +declare interface Window { + convertAuthToken(code: string): void +} \ No newline at end of file diff --git a/fission/src/aps/APS.ts b/fission/src/aps/APS.ts index f1be40ad7d..4873d92136 100644 --- a/fission/src/aps/APS.ts +++ b/fission/src/aps/APS.ts @@ -201,7 +201,7 @@ class APS { const url = `${ENDPOINT_AUTODESK_AUTHENTICATION_AUTHORIZE}?${params.toString()}` - window.open(url, "_self") + window.open(url) } catch (e) { console.error(e) World.AnalyticsSystem?.Exception("APS Login Failure") diff --git a/fission/src/main.tsx b/fission/src/main.tsx index df3510831d..3b761d8ab3 100644 --- a/fission/src/main.tsx +++ b/fission/src/main.tsx @@ -2,6 +2,7 @@ import ReactDOM from "react-dom/client" import { Theme, ThemeProvider } from "@/ui/ThemeContext" import Synthesis from "./Synthesis" import "./index.css" +import APS from "./aps/APS" const initialThemeName = "Default" const defaultColors: Theme = { @@ -72,6 +73,8 @@ const themes = { Default: defaultColors, } +window.convertAuthToken = code => APS.convertAuthToken(code) + ReactDOM.createRoot(document.getElementById("root")!).render(