refactor(types): add StorageChangesObject type

This commit is contained in:
Max Baumann
2020-12-15 14:24:29 +01:00
parent dc36e8097d
commit 094ef84f15
3 changed files with 8 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import * as CompileConfig from "../config.json";
import { CategorySelection, CategorySkipOption, PreviewBarOption, SponsorTime } from "./types";
import { CategorySelection, CategorySkipOption, PreviewBarOption, SponsorTime, StorageChangesObject } from "./types";
import Utils from "./utils";
const utils = new Utils();
@@ -59,7 +59,7 @@ interface SBConfig {
}
export interface SBObject {
configListeners: Array<Function>;
configListeners: Array<(changes: StorageChangesObject) => unknown>;
defaults: SBConfig;
localConfig: SBConfig;
config: SBConfig;
@@ -276,7 +276,7 @@ function decodeStoredItem<T>(id: string, data: T): T | SBMap<string, SponsorTime
}
function configProxy(): any {
chrome.storage.onChanged.addListener((changes) => {
chrome.storage.onChanged.addListener((changes: {[key: string]: chrome.storage.StorageChange}) => {
for (const key in changes) {
Config.localConfig[key] = decodeStoredItem(key, changes[key].newValue);
}