Merge pull request #1330 from bershanskiy/history

Use Navigation API when available
This commit is contained in:
Ajay Ramachandran
2022-06-02 02:30:57 -04:00
committed by GitHub
3 changed files with 53 additions and 7 deletions

View File

@@ -102,9 +102,11 @@ export type VideoDownvotes = { segments: { uuid: HashedValue, hidden: SponsorHid
interface SBStorage {
/* VideoID prefixes to UUID prefixes */
downvotedSegments: Record<VideoID & HashedValue, VideoDownvotes>,
navigationApiAvailable: boolean,
}
export interface SBObject {
configLocalListeners: Array<(changes: StorageChangesObject) => unknown>;
configSyncListeners: Array<(changes: StorageChangesObject) => unknown>;
syncDefaults: SBConfig;
localDefaults: SBStorage;
@@ -121,6 +123,7 @@ const Config: SBObject = {
/**
* Callback function when an option is updated
*/
configLocalListeners: [],
configSyncListeners: [],
syncDefaults: {
userID: null,
@@ -285,7 +288,8 @@ const Config: SBObject = {
}
},
localDefaults: {
downvotedSegments: {}
downvotedSegments: {},
navigationApiAvailable: null
},
cachedSyncConfig: null,
cachedLocalStorage: null,
@@ -312,6 +316,10 @@ function configProxy(): { sync: SBConfig, local: SBStorage } {
for (const key in changes) {
Config.cachedLocalStorage[key] = changes[key].newValue;
}
for (const callback of Config.configLocalListeners) {
callback(changes);
}
}
});