diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index f783e7a..645c98f 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -141,11 +141,16 @@ function setupSafeAreaEmulation(name: string) { } } +const $$SAFE_AREA_EMU = "$$SAFE_AREA_EMU"; + if (import.meta.hot) { - import.meta.hot.accept((mod) => { - if (!mod) return; + import.meta.hot.on("vite:beforeUpdate", () => { + import.meta.hot!.data[$$SAFE_AREA_EMU] = screenOrientationCallback; + }); + + import.meta.hot.on("vite:afterUpdate", () => { + screenOrientationCallback = import.meta.hot?.data?.[$$SAFE_AREA_EMU]; if (screenOrientationCallback) { - mod["screenOrientationCallback"] = screenOrientationCallback; setTimeout(screenOrientationCallback, 0); } });