Define an addEventListener overload in alu.d.ts to prevent an annoying cast in settings.ts
This commit is contained in:
parent
c819bce83e
commit
f7ad2e3ba0
2 changed files with 9 additions and 9 deletions
5
src/alu.d.ts
vendored
5
src/alu.d.ts
vendored
|
|
@ -6,6 +6,11 @@ export declare global {
|
|||
reset: (key: Alu.ValidStoreKeys) => void;
|
||||
};
|
||||
|
||||
// Hacky way to not have to cast the "event" type that lib.dom has to CustomEvent, which is what we actually use.
|
||||
interface Document {
|
||||
addEventListener(type: "setting-tabLoad", listener: (this: Document, ev: CustomEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
|
||||
}
|
||||
|
||||
namespace Alu {
|
||||
let store: AluStore;
|
||||
let settings: {
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ function getLocalStorageValue(localStorageItem: Alu.ValidStoreKeys, dropdownID:
|
|||
const dropdownItem = Array.from(dropdownMenu.children).find((dropdown) => {
|
||||
const itemEl = dropdown as HTMLElement;
|
||||
const item = Alu.store.get(localStorageItem);
|
||||
console.log("Item Value " + item.value);
|
||||
console.log("Dataset Setting " + itemEl.dataset.setting);
|
||||
const find = item.value == itemEl.dataset.setting;
|
||||
if (!find && localStorageItem == "wisp" && item.isCustom) {
|
||||
// This means we are on localhost, default to custom and return it's innerText (This is a hack)
|
||||
|
|
@ -140,11 +138,10 @@ function applyDropdownEventListeners(dropdown: HTMLElement | null, optionalCallb
|
|||
Alu.store.set(localStorageItem, localStorageItemContent);
|
||||
applySavedLocalStorage(localStorageItem, dropdown.id);
|
||||
closeDropdown(dropdownSibling.id);
|
||||
if (typeof optionalCallback === "function") {
|
||||
optionalCallback();
|
||||
}
|
||||
return optionalCallback?.();
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function applyInputListeners(inputs: HTMLInputElement[], localStorageItem: Alu.ValidStoreKeys[]) {
|
||||
|
|
@ -188,8 +185,6 @@ function addThemeToDropdown(extension: ExtensionMetadata) {
|
|||
}
|
||||
}
|
||||
|
||||
loadContent("setting-tab-proxy");
|
||||
|
||||
function setupProxySettings() {
|
||||
applySavedLocalStorage("proxy", "dropdown__selected-proxy");
|
||||
applySavedLocalStorage("search", "dropdown__search-engine");
|
||||
|
|
@ -369,8 +364,7 @@ function checkCustomWisp() {
|
|||
}
|
||||
|
||||
document.addEventListener("setting-tabLoad", (event) => {
|
||||
// I hate doing this :/
|
||||
setupSettings(event as CustomEvent);
|
||||
setupSettings(event);
|
||||
});
|
||||
|
||||
function navigateToNewLangaugePage() {
|
||||
|
|
@ -383,4 +377,5 @@ document.addEventListener("astro:after-swap", () => {
|
|||
settingsLoad();
|
||||
loadContent("setting-tab-proxy");
|
||||
});
|
||||
loadContent("setting-tab-proxy");
|
||||
settingsLoad();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue