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 bkelement = document.getElementById('whatsnewbk')
const popup = document.getElementsByClassName('whatsnewContainer')[0] const popup = document.getElementsByClassName('whatsnewContainer')[0]
if (!settingsState.animations) return; if (!settingsState.animations) {
bkelement?.remove()
return
};
animate( animate(
[popup, bkelement!], [popup, bkelement!],
{ opacity: [1, 0], scale: [1, 0] }, { opacity: [1, 0], scale: [1, 0] },
{ easing: [.22, .03, .26, 1] } { easing: [.22, .03, .26, 1] }
).finished.then(() => { ).finished.then(() => {
bkelement!.remove() bkelement?.remove()
}); });
} }
@@ -734,20 +737,25 @@ function ChangeMenuItemPositions(storage: any) {
} }
export async function ObserveMenuItemPosition() { 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) { await waitForElm('#menu > ul > li')
mutations_list.forEach(function (mutation) { await delay(100)
mutation.addedNodes.forEach(function (added_node) {
const node = added_node as HTMLElement eventManager.register('menuList', {
parentElement: document.querySelector('#menu')!.firstChild as Element,
}, (element: Element) => {
const node = element as HTMLElement;
if (!node?.dataset?.checked && !MenuOptionsOpen) { 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) { if (key) {
console.log('replacing!')
ReplaceMenuSVG( ReplaceMenuSVG(
node, node,
MenuitemSVGKey[node.dataset.key as keyof typeof MenuitemSVGKey], MenuitemSVGKey[node.dataset.key as keyof typeof MenuitemSVGKey],
) );
} else if (node?.firstChild?.nodeName === 'LABEL') { } else if (node?.firstChild?.nodeName === 'LABEL') {
// Assuming `node` is an <li> element containing a <label> // Assuming `node` is an <li> element containing a <label>
const label = node.firstChild as HTMLElement; const label = node.firstChild as HTMLElement;
@@ -765,16 +773,9 @@ export async function ObserveMenuItemPosition() {
label.replaceChild(span, textNode); label.replaceChild(span, textNode);
} }
} }
ChangeMenuItemPositions(menuorder) ChangeMenuItemPositions(settingsState.menuorder);
} }
}) });
})
})
observer.observe(document.querySelector('#menu')!.firstChild!, {
subtree: true,
childList: true,
})
} }
function main() { function main() {
@@ -8,7 +8,6 @@ import {
RemoveShortcutDiv, RemoveShortcutDiv,
addShortcuts, addShortcuts,
disableNotificationCollector, disableNotificationCollector,
documentTextColor,
enableNotificationCollector, enableNotificationCollector,
} from '../../../SEQTA'; } from '../../../SEQTA';
import { updateBgDurations } from '../../ui/Animation'; import { updateBgDurations } from '../../ui/Animation';
@@ -35,7 +34,6 @@ export class StorageChangeHandler {
private handleDarkModeChange() { private handleDarkModeChange() {
updateAllColors(); updateAllColors();
documentTextColor();
} }
private handleOnOffChange() { private handleOnOffChange() {