fix: wait for api b4 hooking into state

This commit is contained in:
dragonwocky 2023-08-06 23:57:37 +10:00
parent 45e0be7d62
commit 95483f4f25
Signed by: dragonwocky
GPG Key ID: 7998D08F7D7BD7A8
2 changed files with 11 additions and 12 deletions

View File

@ -87,11 +87,11 @@ function Panel({
$panel.resize(preDragWidth + (dragStartX - event.clientX)); $panel.resize(preDragWidth + (dragStartX - event.clientX));
}, },
endDrag = (event) => { endDrag = (event) => {
userDragActive = false;
document.removeEventListener("mousemove", onDrag); document.removeEventListener("mousemove", onDrag);
document.removeEventListener("mouseup", endDrag); document.removeEventListener("mouseup", endDrag);
$panel.resize(preDragWidth + (dragStartX - event.clientX)); $panel.resize(preDragWidth + (dragStartX - event.clientX));
$panel.style.transitionDuration = ""; $panel.style.transitionDuration = "";
requestIdleCallback(() => (userDragActive = false));
}; };
$resizeHandle.addEventListener("mousedown", startDrag); $resizeHandle.addEventListener("mousedown", startDrag);

View File

@ -16,11 +16,10 @@ import { Mod } from "./islands/Mod.mjs";
import { Options } from "./islands/Options.mjs"; import { Options } from "./islands/Options.mjs";
import { Profiles } from "./islands/Profiles.mjs"; import { Profiles } from "./islands/Profiles.mjs";
let _apiImported = false, let _apiImport, //
_renderStarted = false, _renderStarted,
_stateHookedInto = false, _stateHookedInto,
_hotkeyRegistered = false; _hotkeyRegistered;
const categories = [ const categories = [
{ {
icon: "palette", icon: "palette",
@ -180,12 +179,12 @@ const renderMenu = async () => {
if (theme === "light") document.body.classList.remove("dark"); if (theme === "light") document.body.classList.remove("dark");
}; };
const importApi = async () => { const importApi = () => {
if (_apiImported) return; return (_apiImport ??= (async () => {
_apiImported = true; const api = globalThis.__enhancerApi;
const api = globalThis.__enhancerApi; if (typeof api === "undefined") await import("../../shared/system.js");
if (typeof api === "undefined") await import("../../shared/system.js"); await import("../../load.mjs").then((i) => i.default);
await import("../../load.mjs").then((i) => i.default); })());
}, },
hookIntoState = () => { hookIntoState = () => {
if (_stateHookedInto) return; if (_stateHookedInto) return;