diff --git a/index.html b/index.html index e06a65b8..77f975ac 100755 --- a/index.html +++ b/index.html @@ -42,6 +42,10 @@ var build = "1511724955"; var version = "3.8.5"; + // Load query param settings + var urlParams = new URLSearchParams(window.location.search); + console.log(urlParams) + // Construct the script tag var js = document.createElement("script"); js.type = "application/javascript"; @@ -69,7 +73,7 @@ js.src = 'https://cdn.rawgit.com/jaedb/Iris/master/mopidy_iris/static/app.min.js?v='+build; css.href = 'https://cdn.rawgit.com/jaedb/Iris/master/mopidy_iris/static/app.min.css?v='+build; - // Initiate error tracking. This helps catch errors early so + // Initiate error tracking. This helps catch errors early so // patches can accurately and quickly fix issues. Raven.config( 'https://023e3bf7721b48f29948545fc36a4621@sentry.io/219026', diff --git a/src/js/App.js b/src/js/App.js index d3e10e82..d668ee93 100755 --- a/src/js/App.js +++ b/src/js/App.js @@ -50,6 +50,7 @@ import ImageZoom from './views/modals/ImageZoom'; import EditCommand from './views/modals/EditCommand'; import { scrollTo, isTouchDevice } from './util/helpers'; +import storage from './util/storage'; import * as coreActions from './services/core/actions'; import * as uiActions from './services/ui/actions'; import * as pusherActions from './services/pusher/actions'; @@ -62,6 +63,27 @@ import * as snapcastActions from './services/snapcast/actions'; export class App extends React.Component { constructor(props) { super(props); + + // Load query param settings + const configs = ['ui', 'spotify', 'pusher', 'snapcast', 'mopidy', 'google', 'lastfm', 'genius'] + const params = new URLSearchParams(window.location.search) + var changed = [] + var urlParams = params.forEach((v, k) => { + if (!configs.includes(k)) return; + try { + storage.set(k, JSON.parse(v)) + changed.push(k) + } catch (error) { + console.error(error) + } + }) + if (changed.length > 0) { + changed.forEach((k) => params.delete(k)) + const url = window.location.toString().replace(window.location.search, params.toString()) + console.log('settings changed:', changed, 'redirect to:', url) + window.location.assign(url) + } + this.handleInstallPrompt = this.handleInstallPrompt.bind(this); this.handleFocusAndBlur = this.handleFocusAndBlur.bind(this); }