Process action naming convention
This commit is contained in:
@ -5,12 +5,12 @@ import * as helpers from '../../helpers';
|
||||
const uiActions = require('./actions.js');
|
||||
const mopidyActions = require('../mopidy/actions.js');
|
||||
|
||||
const UIMiddleware = (function () {
|
||||
const UIMiddleware = (function () {
|
||||
/**
|
||||
* The actual middleware inteceptor
|
||||
* */
|
||||
return (store) => (next) => (action) => {
|
||||
switch (action.type) {
|
||||
switch (action.type) {
|
||||
case 'MOPIDY_STATE':
|
||||
|
||||
// Get the current track from our index
|
||||
@ -117,7 +117,7 @@ const UIMiddleware = (function () {
|
||||
|
||||
// start a timeout to close this notification
|
||||
if (!action.notification.sticky) {
|
||||
var timeout = setTimeout(
|
||||
setTimeout(
|
||||
() => {
|
||||
store.dispatch(uiActions.closeNotification(action.notification.key));
|
||||
},
|
||||
@ -133,7 +133,7 @@ const UIMiddleware = (function () {
|
||||
|
||||
// start a timeout to remove this notification
|
||||
// This gives us time to animate out the notification before we remove the data
|
||||
var timeout = setTimeout(
|
||||
setTimeout(
|
||||
() => {
|
||||
store.dispatch(uiActions.removeNotification(action.key));
|
||||
},
|
||||
@ -214,32 +214,51 @@ const UIMiddleware = (function () {
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'PROCESS_FINISHING':
|
||||
|
||||
// start a timeout to remove this notification
|
||||
// This gives us time to animate out the notification before we remove the data
|
||||
var timeout = setTimeout(
|
||||
() => {
|
||||
store.dispatch(uiActions.processFinished(action.key));
|
||||
},
|
||||
200,
|
||||
);
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'PROCESS_FINISHED':
|
||||
store.dispatch({
|
||||
type: `${action.key}_FINISHED`,
|
||||
});
|
||||
|
||||
// start a timeout to remove this notification
|
||||
// This gives us time to animate out the notification before we remove the data
|
||||
if (action.completionMessage) {
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
action.key,
|
||||
action.completionMessage.content,
|
||||
{},
|
||||
action.completionMessage.description,
|
||||
action.completionMessage.level,
|
||||
));
|
||||
if (!action.completionMessage.sticky) {
|
||||
setTimeout(
|
||||
() => {
|
||||
store.dispatch(uiActions.closeProcess(action.key));
|
||||
},
|
||||
5000,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
store.dispatch(uiActions.closeProcess(action.key));
|
||||
}
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
case 'CLOSE_PROCESS':
|
||||
setTimeout(
|
||||
() => {
|
||||
store.dispatch(uiActions.removeProcess(action.key));
|
||||
},
|
||||
200,
|
||||
);
|
||||
next(action);
|
||||
break;
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
default:
|
||||
return next(action);
|
||||
}
|
||||
};
|
||||
};
|
||||
}());
|
||||
|
||||
export default UIMiddleware;
|
||||
export default UIMiddleware;
|
||||
|
||||
Reference in New Issue
Block a user