Skip to content

Commit a0b51b4

Browse files
authored
Merge pull request #217 from Brskt/fix-nativefullscreen
[NativeFullscreen] Fix hideTopBar and exitFullscreen issues
2 parents 1390e9b + 82f0e05 commit a0b51b4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

plugins/NativeFullscreen/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { LunaUnload } from "@luna/core";
2-
import { redux } from "@luna/lib";
2+
import { observePromise, redux } from "@luna/lib";
33
import { storage } from "./Settings";
44
export { Settings } from "./Settings";
55

@@ -16,7 +16,12 @@ export const setTopBarVisibility = (visible: boolean) => {
1616
const bar = document.querySelector<HTMLElement>("div[class^='_bar']");
1717
if (bar) bar.style.display = visible ? "" : "none";
1818
};
19-
if (storage.hideTopBar) setTopBarVisibility(false);
19+
// Apply hideTopBar setting on load
20+
if (storage.hideTopBar) {
21+
observePromise<HTMLElement>(unloads, "div[class^='_bar']").then((bar) => {
22+
if (bar) setTopBarVisibility(false);
23+
});
24+
}
2025

2126
const onKeyDown = (event: KeyboardEvent) => {
2227
if (event.key === "F11") {
@@ -27,7 +32,7 @@ const onKeyDown = (event: KeyboardEvent) => {
2732

2833
if (document.fullscreenElement || wimp?.classList.contains("is-fullscreen")) {
2934
// Exiting fullscreen
30-
document.exitFullscreen();
35+
if (document.fullscreenElement) document.exitFullscreen();
3136
if (wimp) wimp.classList.remove("is-fullscreen");
3237
if (!storage.hideTopBar) setTopBarVisibility(true);
3338
if (contentContainer) contentContainer.style.maxHeight = "";

0 commit comments

Comments
 (0)