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
+42 -41
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,47 +737,45 @@ 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', {
if (!node?.dataset?.checked && !MenuOptionsOpen) { parentElement: document.querySelector('#menu')!.firstChild as Element,
const key = MenuitemSVGKey[node?.dataset?.key! as keyof typeof MenuitemSVGKey] }, (element: Element) => {
if (key) { const node = element as HTMLElement;
ReplaceMenuSVG( if (!node?.dataset?.checked && !MenuOptionsOpen) {
node, const key = MenuitemSVGKey[node?.dataset?.key! as keyof typeof MenuitemSVGKey];
MenuitemSVGKey[node.dataset.key as keyof typeof MenuitemSVGKey], console.log("Key: ", key)
) if (key) {
} else if (node?.firstChild?.nodeName === 'LABEL') { console.log('replacing!')
// Assuming `node` is an <li> element containing a <label> ReplaceMenuSVG(
const label = node.firstChild as HTMLElement; node,
MenuitemSVGKey[node.dataset.key as keyof typeof MenuitemSVGKey],
// The magical step: We find the last child. If it's a text node, embrace it with <span> );
let textNode = label.lastChild as HTMLElement; } else if (node?.firstChild?.nodeName === 'LABEL') {
// Assuming `node` is an <li> element containing a <label>
// A quick check to ensure it's a text node and not already ensconced in a <span> const label = node.firstChild as HTMLElement;
if (textNode.nodeType === 3 && textNode.parentNode && textNode.parentNode.nodeName !== 'SPAN') {
// The text node is indeed bare, and not in a <span>. Time to act! // The magical step: We find the last child. If it's a text node, embrace it with <span>
const span = document.createElement('span'); // The creation of the <span> let textNode = label.lastChild as HTMLElement;
span.textContent = textNode.nodeValue; // Transferring the text
// A quick check to ensure it's a text node and not already ensconced in a <span>
// Replacing the text node with our newly minted <span> full of text if (textNode.nodeType === 3 && textNode.parentNode && textNode.parentNode.nodeName !== 'SPAN') {
label.replaceChild(span, textNode); // The text node is indeed bare, and not in a <span>. Time to act!
} const span = document.createElement('span'); // The creation of the <span>
} span.textContent = textNode.nodeValue; // Transferring the text
ChangeMenuItemPositions(menuorder)
// Replacing the text node with our newly minted <span> full of text
label.replaceChild(span, textNode);
} }
}) }
}) 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() {