fix: update popup not closing with animations disabled

This commit is contained in:
sethburkart123
2024-06-19 16:58:41 +10:00
parent 0c4b8521b4
commit 76101350ef
2 changed files with 42 additions and 43 deletions
+20 -19
View File
@@ -335,14 +335,17 @@ async function DeleteWhatsNew() {
const bkelement = document.getElementById('whatsnewbk')
const popup = document.getElementsByClassName('whatsnewContainer')[0]
if (!settingsState.animations) return;
if (!settingsState.animations) {
bkelement?.remove()
return
};
animate(
[popup, bkelement!],
{ opacity: [1, 0], scale: [1, 0] },
{ easing: [.22, .03, .26, 1] }
).finished.then(() => {
bkelement!.remove()
bkelement?.remove()
});
}
@@ -734,20 +737,25 @@ function ChangeMenuItemPositions(storage: any) {
}
export async function ObserveMenuItemPosition() {
let menuorder = settingsState.menuorder
if (!(menuorder && settingsState.onoff)) return;
//if (!(menuorder && settingsState.onoff)) return;
console.log(document.querySelector('#menu')!.firstChild)
const observer = new MutationObserver(function (mutations_list) {
mutations_list.forEach(function (mutation) {
mutation.addedNodes.forEach(function (added_node) {
const node = added_node as HTMLElement
await waitForElm('#menu > ul > li')
await delay(100)
eventManager.register('menuList', {
parentElement: document.querySelector('#menu')!.firstChild as Element,
}, (element: Element) => {
const node = element as HTMLElement;
if (!node?.dataset?.checked && !MenuOptionsOpen) {
const key = MenuitemSVGKey[node?.dataset?.key! as keyof typeof MenuitemSVGKey]
const key = MenuitemSVGKey[node?.dataset?.key! as keyof typeof MenuitemSVGKey];
console.log("Key: ", key)
if (key) {
console.log('replacing!')
ReplaceMenuSVG(
node,
MenuitemSVGKey[node.dataset.key as keyof typeof MenuitemSVGKey],
)
);
} else if (node?.firstChild?.nodeName === 'LABEL') {
// Assuming `node` is an <li> element containing a <label>
const label = node.firstChild as HTMLElement;
@@ -765,16 +773,9 @@ export async function ObserveMenuItemPosition() {
label.replaceChild(span, textNode);
}
}
ChangeMenuItemPositions(menuorder)
ChangeMenuItemPositions(settingsState.menuorder);
}
})
})
})
observer.observe(document.querySelector('#menu')!.firstChild!, {
subtree: true,
childList: true,
})
});
}
function main() {
@@ -8,7 +8,6 @@ import {
RemoveShortcutDiv,
addShortcuts,
disableNotificationCollector,
documentTextColor,
enableNotificationCollector,
} from '../../../SEQTA';
import { updateBgDurations } from '../../ui/Animation';
@@ -35,7 +34,6 @@ export class StorageChangeHandler {
private handleDarkModeChange() {
updateAllColors();
documentTextColor();
}
private handleOnOffChange() {