diff --git a/app/web/src/index.tsx b/app/web/src/index.tsx index 98100853..b269cb87 100644 --- a/app/web/src/index.tsx +++ b/app/web/src/index.tsx @@ -14,6 +14,7 @@ const start = async () => { let react = { root: null as null | ReactRoot, }; + (window as any).mobile = registerMobile(); if ( !["localhost", "127.0.0.1", "trycloudflare.com", "ngrok"].find((e) => diff --git a/app/web/src/render/live/logic/init.tsx b/app/web/src/render/live/logic/init.tsx index a33a8f93..60643fd1 100644 --- a/app/web/src/render/live/logic/init.tsx +++ b/app/web/src/render/live/logic/init.tsx @@ -32,9 +32,10 @@ export const initLive = async (p: PG, domain_or_siteid: string) => { if (p.status === "init") { p.status = "loading"; - w.mobile = registerMobile(); - w.mobile.bind(p); - w.mobile.send({ type: "ready" }); + if (w.mobile) { + w.mobile.bind(p); + w.mobile.send({ type: "ready" }); + } w.isEditor = false; w.isLayout = true; diff --git a/app/web/src/render/site/site.tsx b/app/web/src/render/site/site.tsx index 81328845..8524e7f3 100644 --- a/app/web/src/render/site/site.tsx +++ b/app/web/src/render/site/site.tsx @@ -2,12 +2,18 @@ import { FC, useState } from "react"; import { createRoot } from "react-dom/client"; import { GlobalContext, defineReact, defineWindow } from "web-utils"; import { siteLoader } from "./site-loader"; +import { registerMobile } from "../live/logic/mobile"; const w = window as unknown as { prasiContext: any; rootRender: any; + mobile: any; }; +if (!w.mobile) { + w.mobile = registerMobile(); +} + w.prasiContext = { global: {}, render() {},