mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
refactor(types): add StorageChangesObject type
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Config from "./config";
|
||||
|
||||
import { SponsorTime, CategorySkipOption, VideoID, SponsorHideType, FetchResponse, VideoInfo } from "./types";
|
||||
import { SponsorTime, CategorySkipOption, VideoID, SponsorHideType, FetchResponse, VideoInfo, StorageChangesObject } from "./types";
|
||||
|
||||
import { ContentContainer } from "./types";
|
||||
import Utils from "./utils";
|
||||
@@ -179,7 +179,7 @@ function messageListener(request: any, sender: any, sendResponse: (response: any
|
||||
*
|
||||
* @param {String} changes
|
||||
*/
|
||||
function contentConfigUpdateListener(changes) {
|
||||
function contentConfigUpdateListener(changes: StorageChangesObject) {
|
||||
for (const key in changes) {
|
||||
switch(key) {
|
||||
case "hideVideoPlayerControls":
|
||||
|
||||
@@ -156,6 +156,8 @@ interface VideoInfo {
|
||||
|
||||
type VideoID = string;
|
||||
|
||||
type StorageChangesObject = { [key: string]: chrome.storage.StorageChange };
|
||||
|
||||
export {
|
||||
FetchResponse,
|
||||
VideoDurationResponse,
|
||||
@@ -169,4 +171,5 @@ export {
|
||||
Registration,
|
||||
BackgroundScriptContainer,
|
||||
VideoInfo,
|
||||
StorageChangesObject,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user