Attempting threading for long-runing system processes

This commit is contained in:
James Barnsley
2018-11-02 10:20:32 +13:00
parent b83043ef4f
commit 4c100a9527
9 changed files with 172 additions and 54 deletions

View File

@ -48,6 +48,12 @@ export function restart(){
}
}
export function runLocalScan(){
return {
type: 'PUSHER_RUN_LOCAL_SCAN'
}
}
export function getConnections(){
return {
type: 'PUSHER_GET_CONNECTIONS'

View File

@ -618,6 +618,11 @@ const PusherMiddleware = (function(){
);
break
/**
* Notifications and alerts
**/
case 'PUSHER_BROWSER_NOTIFICATION':
store.dispatch(uiActions.createBrowserNotification(action))
break
@ -632,6 +637,11 @@ const PusherMiddleware = (function(){
store.dispatch(uiActions.createNotification(data));
break
/**
* Server actions
**/
case 'PUSHER_RELOAD':
// Hard reload. This doesn't strictly clear the cache, but our compiler's
// cache buster should handle that
@ -666,6 +676,21 @@ const PusherMiddleware = (function(){
);
break;
case 'PUSHER_RUN_LOCAL_SCAN':
if (store.getState().ui.allow_reporting){
ReactGA.event({ category: 'Pusher', action: 'Run local scan', label: '' });
}
request(store, 'run_local_scan')
.then(
response => {
store.dispatch(mopidyActions.localScanRunning());
},
error => {
store.dispatch(uiActions.createNotification({content: error.message, description: (error.description ? error.description : null), type: 'bad'}));
}
);
break;
case 'PUSHER_VERSION':
if (store.getState().ui.allow_reporting){
ReactGA.event({ category: 'Pusher', action: 'Version', label: action.version.current });