From d48dd43c94de11c0b42ce20a950bdb19718649fb Mon Sep 17 00:00:00 2001 From: RemixDev Date: Thu, 16 Apr 2020 10:37:02 +0200 Subject: [PATCH] Added Spotify credentials to settings tab Reworked how spotify features work so now it doesn't require restart on config change --- public/index.html | 10 ++++++++++ public/js/app/app.js | 21 +++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/public/index.html b/public/index.html index 986607b..8008892 100644 --- a/public/index.html +++ b/public/index.html @@ -353,6 +353,16 @@

Settings

+
+
+

Spotify clientID

+ +
+
+

Spotify Client Secret

+ +
+
diff --git a/public/js/app/app.js b/public/js/app/app.js index 0322d69..38966d7 100644 --- a/public/js/app/app.js +++ b/public/js/app/app.js @@ -8,6 +8,7 @@ main_selected="" toastsWithId = {} // settings lastSettings = {} +lastCredentials = {} function toast(msg, icon=null, dismiss=true, id=null){ if (toastsWithId[id]){ @@ -23,7 +24,6 @@ function toast(msg, icon=null, dismiss=true, id=null){ icon = `${icon}` toastDOM.find(".toast-icon").html(icon) } - console.log(dismiss) if (dismiss !== null && dismiss){ setTimeout(function(){ toastObj.hideToast() @@ -166,28 +166,33 @@ socket.on("logged_out", function(){ var settingsTab = new Vue({ el: '#settings_tab', data: { - settings: {} + settings: {}, + spotifyFeatures: {} } }) -socket.on("init_settings", function(settings){ - loadSettings(settings) +socket.on("init_settings", function(settings, credentials){ + console.log(settings,credentials) + loadSettings(settings, credentials) toast("Settings loaded!", 'settings') }) -socket.on("updateSettings", function(settings){ - loadSettings(settings) +socket.on("updateSettings", function(settings, credentials){ + loadSettings(settings, credentials) toast("Settings updated!", 'settings') }) -function loadSettings(settings){ +function loadSettings(settings, spotifyCredentials){ lastSettings = {...settings} + lastCredentials = {...spotifyCredentials} settingsTab.settings = settings + settingsTab.spotifyFeatures = spotifyCredentials } function saveSettings(){ lastSettings = {...settingsTab.settings} - socket.emit("saveSettings", lastSettings) + lastCredentials = {...settingsTab.spotifyFeatures} + socket.emit("saveSettings", lastSettings, lastCredentials) } // tabs stuff