fix(in-app-menu): remove unused observer

This commit is contained in:
JellyBrick
2023-10-03 12:56:49 +09:00
parent 2c38b8a764
commit b9ea98c115

View File

@ -7,9 +7,6 @@ import { createPanel } from './menu/panel';
import { ElementFromFile } from '../utils';
import { isEnabled } from '../../config/plugins';
type ElectronCSSStyleDeclaration = CSSStyleDeclaration & { webkitAppRegion: 'drag' | 'no-drag' };
type ElectronHTMLElement = HTMLElement & { style: ElectronCSSStyleDeclaration };
function $<E extends Element = Element>(selector: string) {
return document.querySelector<E>(selector);
}
@ -68,7 +65,6 @@ export default () => {
// Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it)
document.addEventListener('apiLoaded', () => {
setupSearchOpenObserver();
const htmlHeadStyle = $('head > div > style');
if (htmlHeadStyle) {
// HACK: This is a hack to remove the scrollbar width
@ -76,16 +72,3 @@ export default () => {
}
}, { once: true, passive: true });
};
function setupSearchOpenObserver() {
const searchOpenObserver = new MutationObserver((mutations) => {
const navBarBackground = $<ElectronHTMLElement>('#nav-bar-background');
if (navBarBackground) {
navBarBackground.style.webkitAppRegion = (mutations[0].target as HTMLElement & { opened: boolean }).opened ? 'no-drag' : 'drag';
}
});
const searchBox = $('ytmusic-search-box');
if (searchBox) {
searchOpenObserver.observe(searchBox, { attributeFilter: ['opened'] });
}
}