From da17dd8bae356d974edae2bb0000d5d174977ef5 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Tue, 31 Dec 2019 22:46:16 +0000 Subject: [PATCH] Added addDefaults and resetConfig --- SB.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/SB.js b/SB.js index 75b98294..89332ae5 100644 --- a/SB.js +++ b/SB.js @@ -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();