Merging url-based imports
This commit is contained in:
@ -51,6 +51,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';
|
||||
@ -63,6 +64,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);
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
import ReactGA from 'react-ga';
|
||||
import { formatUser } from '../../util/format';
|
||||
const coreActions = require('../core/actions');
|
||||
const uiActions = require('../ui/actions');
|
||||
const lastfmActions = require('./actions');
|
||||
|
||||
const LastfmMiddleware = (function () {
|
||||
@ -25,6 +27,27 @@ const LastfmMiddleware = (function () {
|
||||
// TODO: Use callbacks for better code accuracy
|
||||
setTimeout(() => { store.dispatch(lastfmActions.getMe()); }, 100);
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'LASTFM_AUTHORIZATION_REVOKED':
|
||||
if (store.getState().ui.allow_reporting) {
|
||||
ReactGA.event({ category: 'LastFM', action: 'Authorization revoked' });
|
||||
}
|
||||
|
||||
store.dispatch(uiActions.createNotification({
|
||||
content: 'Logout successful',
|
||||
description: 'If you have shared your authorization, make sure you revoke your token',
|
||||
sticky: true,
|
||||
links: [
|
||||
{
|
||||
url: 'https://www.last.fm/settings/applications',
|
||||
text: 'Authorized apps',
|
||||
new_window: true,
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import {
|
||||
formatUser,
|
||||
} from '../../util/format';
|
||||
const coreActions = require('../core/actions');
|
||||
const uiActions = require('../ui/actions');
|
||||
const spotifyActions = require('./actions');
|
||||
const pusherActions = require('../pusher/actions');
|
||||
|
||||
@ -31,8 +32,21 @@ const SpotifyMiddleware = (function () {
|
||||
|
||||
case 'SPOTIFY_AUTHORIZATION_REVOKED':
|
||||
if (store.getState().ui.allow_reporting) {
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization revoked' });
|
||||
}
|
||||
ReactGA.event({ category: 'Spotify', action: 'Authorization revoked' });
|
||||
}
|
||||
|
||||
store.dispatch(uiActions.createNotification({
|
||||
content: 'Logout successful',
|
||||
description: 'If you have shared your authorization, make sure you revoke your token',
|
||||
sticky: true,
|
||||
links: [
|
||||
{
|
||||
url: 'https://www.spotify.com/nz/account/apps/',
|
||||
text: 'Authorized apps',
|
||||
new_window: true,
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
next(action);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user