diff --git a/plugins/NativeFullscreen/src/index.ts b/plugins/NativeFullscreen/src/index.ts index 4f00a852..6d8c5070 100644 --- a/plugins/NativeFullscreen/src/index.ts +++ b/plugins/NativeFullscreen/src/index.ts @@ -1,5 +1,5 @@ import type { LunaUnload } from "@luna/core"; -import { redux } from "@luna/lib"; +import { observePromise, redux } from "@luna/lib"; import { storage } from "./Settings"; export { Settings } from "./Settings"; @@ -16,7 +16,12 @@ export const setTopBarVisibility = (visible: boolean) => { const bar = document.querySelector("div[class^='_bar']"); if (bar) bar.style.display = visible ? "" : "none"; }; -if (storage.hideTopBar) setTopBarVisibility(false); +// Apply hideTopBar setting on load +if (storage.hideTopBar) { + observePromise(unloads, "div[class^='_bar']").then((bar) => { + if (bar) setTopBarVisibility(false); + }); +} const onKeyDown = (event: KeyboardEvent) => { if (event.key === "F11") { @@ -27,7 +32,7 @@ const onKeyDown = (event: KeyboardEvent) => { if (document.fullscreenElement || wimp?.classList.contains("is-fullscreen")) { // Exiting fullscreen - document.exitFullscreen(); + if (document.fullscreenElement) document.exitFullscreen(); if (wimp) wimp.classList.remove("is-fullscreen"); if (!storage.hideTopBar) setTopBarVisibility(true); if (contentContainer) contentContainer.style.maxHeight = "";