Added addDefaults and resetConfig

This commit is contained in:
Official Noob
2019-12-31 22:46:16 +00:00
committed by GitHub
parent 87098d1c3e
commit da17dd8bae

23
SB.js
View File

@@ -27,10 +27,31 @@ fetchConfig = _ => new Promise(function(resolve, reject) {
});
async function config() {
SB.localconfig = {};
await fetchConfig();
addDefaults();
SB.config = configProxy();
}
SB.defaults = {
"startSponsorKeybind": ";",
"submitKeybind": "'",
"minutesSaved": 0,
"skipCount": 0
}
// Reset config
function resetConfig() {
SB.config = SB.defaults;
};
// Add defaults
function addDefaults() {
Object.keys(SB.defaults).forEach(key => {
if(!SB.localconfig.hasOwnProperty(key)) {
SB.localconfig = SB.defaults[key];
}
});
};
// Sync config
config();