Removing r test_mode from redux-persist, use localStorage directly and URL vars to switch
This commit is contained in:
@ -119,17 +119,14 @@
|
||||
|
||||
// Check for test mode. This is toggled under Settings > Debug > Test mode or can
|
||||
// be manually triggered with the URL var "?test_mode=1"
|
||||
try {
|
||||
var ui = JSON.parse(localStorage.getItem('ui') );
|
||||
window.test_mode = (
|
||||
typeof(ui) !== 'undefined'
|
||||
&& ui
|
||||
&& typeof(ui.test_mode) !== 'undefined'
|
||||
&& ui.test_mode
|
||||
) || window.location.href.indexOf('test_mode=1') > -1;
|
||||
} catch(error){
|
||||
console.error(error);
|
||||
if (window.location.href.indexOf('test_mode=1') > -1) {
|
||||
window.test_mode = true;
|
||||
localStorage.setItem('test_mode', true);
|
||||
} else if (window.location.href.indexOf('test_mode=0') > -1) {
|
||||
window.test_mode = false;
|
||||
localStorage.removeItem('test_mode');
|
||||
} else {
|
||||
window.test_mode = localStorage.getItem('test_mode');
|
||||
}
|
||||
|
||||
// Test mode, use un-minified code
|
||||
|
||||
@ -55,21 +55,19 @@ class Debug extends React.Component {
|
||||
debug(JSON.parse(snapcast_data));
|
||||
}
|
||||
|
||||
toggleTestMode = (e) => {
|
||||
toggleTestMode = () => {
|
||||
const { uiActions: { set }, test_mode } = this.props;
|
||||
this.setState({ toggling_test_mode: true });
|
||||
set({ test_mode: !test_mode });
|
||||
|
||||
// Wait a second to allow state to update, and then refresh
|
||||
setTimeout(location.reload(), 1000);
|
||||
setTimeout(location.reload(), 2500);
|
||||
}
|
||||
|
||||
render = () => {
|
||||
const {
|
||||
uiActions,
|
||||
spotifyActions,
|
||||
history,
|
||||
test_mode,
|
||||
debug_response,
|
||||
debug_info,
|
||||
log_actions,
|
||||
@ -79,12 +77,12 @@ class Debug extends React.Component {
|
||||
access_token,
|
||||
} = this.props;
|
||||
const {
|
||||
toggling_test_mode,
|
||||
mopidy_call,
|
||||
mopidy_data,
|
||||
pusher_data,
|
||||
snapcast_data,
|
||||
} = this.state;
|
||||
const { test_mode } = window;
|
||||
|
||||
const options = (
|
||||
<Button
|
||||
@ -113,8 +111,7 @@ class Debug extends React.Component {
|
||||
<div className="input">
|
||||
<Button
|
||||
type={test_mode ? 'destructive' : null}
|
||||
working={toggling_test_mode}
|
||||
onClick={this.toggleTestMode}
|
||||
href={`?test_mode=${test_mode ? '0' : '1'}`}
|
||||
tracking={{ category: 'Debug', action: 'TestMode', label: test_mode ? 'Disable' : 'Enable' }}
|
||||
>
|
||||
<I18n path={`actions.${test_mode ? 'disable' : 'enable'}`} />
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"manifest_version": "3.44",
|
||||
"manifest_version": "3.53",
|
||||
"short_name": "Iris",
|
||||
"name": "Iris",
|
||||
"icons": [
|
||||
|
||||
Reference in New Issue
Block a user