Skip to content

Commit

Permalink
remove clickoff checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Endercass committed Sep 14, 2024
1 parent ac5ee81 commit 7fda876
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 90 deletions.
47 changes: 4 additions & 43 deletions src/Boot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,6 @@ channel.addEventListener("message", (msg) => {
}
});

const clickoffCheckerState = $state({
active: false,
});

const clickoffChecker = (
<div
class={[
use(clickoffCheckerState.active, (active) =>
active
? css`
position: absolute;
width: 100%;
height: 100%;
display: block;
z-index: 9998;
`
: css`
display: none;
`,
),
]}
/>
);

const updateClickoffChecker = (show: boolean) => {
clickoffCheckerState.active = show;
};

let taskbar: Taskbar;
let launcher: Launcher;
let oobeview: OobeView;
Expand Down Expand Up @@ -342,20 +314,9 @@ window.addEventListener("load", async () => {
// console.log(await swProxy.test);
// console.log(await swProxy.testfn());

launcher = new Launcher(
clickoffChecker as HTMLDivElement,
updateClickoffChecker,
);

quickSettings = new QuickSettings(
clickoffChecker as HTMLDivElement,
updateClickoffChecker,
);

calendar = new Calendar(
clickoffChecker as HTMLDivElement,
updateClickoffChecker,
);
launcher = new Launcher();
quickSettings = new QuickSettings();
calendar = new Calendar();

taskbar = new Taskbar();

Expand Down Expand Up @@ -607,7 +568,6 @@ document.addEventListener("anura-login-completed", async () => {
}

document.body.appendChild(launcher.element);
document.body.appendChild(launcher.clickoffChecker);
document.body.appendChild(quickSettings.quickSettingsElement);
document.body.appendChild(calendar.element);
document.body.appendChild(quickSettings.notificationCenterElement);
Expand Down Expand Up @@ -651,6 +611,7 @@ document.addEventListener("anura-login-completed", async () => {
e.key.toLowerCase() === "meta" &&
anura.settings.get("launcher-keybind")
) {
e.stopPropagation();
quickSettings.close();
calendar.close();
launcher.toggleVisible();
Expand Down
23 changes: 8 additions & 15 deletions src/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ class Calendar {
z-index: -1;
`;

clickoffChecker: HTMLDivElement;
updateClickoffChecker: (show: boolean) => void;

open() {
this.state.show = true;
}
Expand All @@ -182,15 +179,14 @@ class Calendar {
}
}

constructor(
clickoffChecker: HTMLDivElement,
updateClickoffChecker: (show: boolean) => void,
) {
clickoffChecker.addEventListener("click", () => {
this.state.show = false;
});
this.clickoffChecker = clickoffChecker;
this.updateClickoffChecker = updateClickoffChecker;
constructor() {
document.addEventListener(
"click",
(e) =>
this.state.show &&
!this.element.contains(e.target as Node) &&
this.close(),
);
}

async init() {
Expand Down Expand Up @@ -326,9 +322,6 @@ class Calendar {
day!.innerHTML = lit;
};

useChange(use(this.state.show), (show: boolean) => {
this.updateClickoffChecker(show);
});
setTimeout(() => {
manipulate();
const prenexIcons = document.querySelectorAll(
Expand Down
20 changes: 5 additions & 15 deletions src/Launcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ class Launcher {

element = (<div>Not Initialized</div>);

clickoffChecker: HTMLDivElement;
updateClickoffChecker: (show: boolean) => void;

handleSearch(event: Event) {
const searchQuery = (
event.target as HTMLInputElement
Expand Down Expand Up @@ -185,18 +182,11 @@ class Launcher {
this.state.apps = [...(this.state.apps || []), app];
}

constructor(
clickoffChecker: HTMLDivElement,
updateClickoffChecker: (show: boolean) => void,
) {
clickoffChecker.addEventListener("click", () => {
this.state.active = false;
});

this.clickoffChecker = clickoffChecker;
this.updateClickoffChecker = updateClickoffChecker;

useChange(use(this.state.active), updateClickoffChecker);
constructor() {
document.addEventListener(
"click",
(e) => !this.element.contains(e.target as Node) && this.hide(),
);
}

async init() {
Expand Down
32 changes: 18 additions & 14 deletions src/QuickSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ class QuickSettings {

notificationCenterElement = (<div>Not Initialized</div>);

clickoffChecker: HTMLDivElement;
updateClickoffChecker: (show: boolean) => void;

open() {
// reason for this is otherwise dreamland doesn't run the use() dunno why
const pinnedSettings = this.state.pinnedSettings;
Expand All @@ -249,20 +246,28 @@ class QuickSettings {
}
}

constructor(
clickoffChecker: HTMLDivElement,
updateClickoffChecker: (show: boolean) => void,
) {
clickoffChecker.addEventListener("click", () => {
this.state.showQuickSettings = false;
constructor() {
document.addEventListener("click", (e) => {
const target = e.target as HTMLElement;
if (
this.state.showQuickSettings &&
// HACK HACK DUMB HACK
// Quick settings icons sometimes do not think that they are
// children of the DOM so they will also not pass the check
// that they are children of the menu.
document.contains(target) &&
!(
this.quickSettingsElement.contains(target) ||
this.notificationCenterElement.contains(target)
)
) {
this.close();
}
});

setInterval(() => {
this.state.date = this.dateformat.format(new Date());
this.state.date = this.dateformat.format(Date.now());
}, 1000);

this.clickoffChecker = clickoffChecker;
this.updateClickoffChecker = updateClickoffChecker;
}

async init() {
Expand Down Expand Up @@ -528,7 +533,6 @@ class QuickSettings {
// });

useChange(use(this.state.showQuickSettings), (show: boolean) => {
this.updateClickoffChecker(show);
anura.notifications.setRender(!show);
});
}
Expand Down
9 changes: 6 additions & 3 deletions src/Taskbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ class Taskbar {
<div id="launcher-button-container">
<div
id="launcher-button"
on:click={() => {
on:click={(e: InputEvent) => {
e.stopPropagation();
quickSettings.close();
calendar.close();
launcher.toggleVisible();
Expand Down Expand Up @@ -374,7 +375,8 @@ class Taskbar {
{/* TODO: Calendar */}
<span
id="date-container"
on:click={() => {
on:click={(e: InputEvent) => {
e.stopPropagation();
launcher.hide();
quickSettings.close();
calendar.toggle();
Expand All @@ -384,7 +386,8 @@ class Taskbar {
</span>
<span
id="taskinfo-container"
on:click={() => {
on:click={(e: InputEvent) => {
e.stopPropagation();
launcher.hide();
calendar.close();
quickSettings.toggle();
Expand Down

0 comments on commit 7fda876

Please sign in to comment.