From 7562d9b533677b332b5e11b82d9c24b4b0052e08 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Wed, 1 Feb 2023 06:16:17 +0100 Subject: [PATCH] fix: make tunnels work in multi-instance scenarios (#6178) * fix: make tunnels work in multi-instance scenarios * factor tunnels out * use tunnel-rat fork until upsteam updated --- package.json | 1 + src/components/LayerUI.tsx | 29 ++++++++++------- src/components/MobileMenu.tsx | 3 +- src/components/context/tunnels.ts | 32 +++++++++++++++++++ src/components/footer/Footer.tsx | 4 ++- src/components/footer/FooterCenter.tsx | 3 +- src/components/hoc/withInternalFallback.tsx | 4 ++- src/components/main-menu/MainMenu.tsx | 3 +- src/components/tunnels.ts | 8 ----- .../welcome-screen/WelcomeScreen.Center.tsx | 3 +- .../welcome-screen/WelcomeScreen.Hints.tsx | 9 +++--- yarn.lock | 9 +++++- 12 files changed, 76 insertions(+), 32 deletions(-) create mode 100644 src/components/context/tunnels.ts delete mode 100644 src/components/tunnels.ts diff --git a/package.json b/package.json index 8d117ea9..a19b2fb8 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ ] }, "dependencies": { + "@dwelle/tunnel-rat": "0.1.1", "@sentry/browser": "6.2.5", "@sentry/integrations": "6.2.5", "@testing-library/jest-dom": "5.16.2", diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index 380c01c1..16151200 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -40,17 +40,12 @@ import { actionToggleStats } from "../actions/actionToggleStats"; import Footer from "./footer/Footer"; import { hostSidebarCountersAtom } from "./Sidebar/Sidebar"; import { jotaiScope } from "../jotai"; -import { useAtom } from "jotai"; +import { Provider, useAtom } from "jotai"; import MainMenu from "./main-menu/MainMenu"; import { ActiveConfirmDialog } from "./ActiveConfirmDialog"; import { HandButton } from "./HandButton"; import { isHandToolActive } from "../appState"; -import { - mainMenuTunnel, - welcomeScreenMenuHintTunnel, - welcomeScreenToolbarHintTunnel, - welcomeScreenCenterTunnel, -} from "./tunnels"; +import { TunnelsContext, useInitializeTunnels } from "./context/tunnels"; interface LayerUIProps { actionManager: ActionManager; @@ -130,6 +125,8 @@ const LayerUI = ({ }: LayerUIProps) => { const device = useDevice(); + const tunnels = useInitializeTunnels(); + const renderJSONExportDialog = () => { if (!UIOptions.canvasActions.export) { return null; @@ -201,8 +198,8 @@ const LayerUI = ({
{/* wrapping to Fragment stops React from occasionally complaining about identical Keys */} - - {renderWelcomeScreen && } + + {renderWelcomeScreen && }
); @@ -254,7 +251,7 @@ const LayerUI = ({ {(heading: React.ReactNode) => (
{renderWelcomeScreen && ( - + )} {/* ------------------------- tunneled UI ---------------------------- */} {/* make sure we render host app components first so that we can detect @@ -434,7 +431,7 @@ const LayerUI = ({ : {} } > - {renderWelcomeScreen && } + {renderWelcomeScreen && } {renderFixedSideContainer()}