|
|
@ -17,6 +17,7 @@ export const section = 'commands';
|
|
|
|
let lastCommand = null;
|
|
|
|
let lastCommand = null;
|
|
|
|
let lastCommandTimeout = null;
|
|
|
|
let lastCommandTimeout = null;
|
|
|
|
const removeCommandTimeoutIds = {};
|
|
|
|
const removeCommandTimeoutIds = {};
|
|
|
|
|
|
|
|
const commandFinishedCallbacks = {};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// State
|
|
|
|
// State
|
|
|
@ -136,14 +137,23 @@ export function executeCommandHelper( payload, dispatch) {
|
|
|
|
lastCommand = null;
|
|
|
|
lastCommand = null;
|
|
|
|
}, 5000);
|
|
|
|
}, 5000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
|
|
commandFinished,
|
|
|
|
|
|
|
|
...requestPayload
|
|
|
|
|
|
|
|
} = payload;
|
|
|
|
|
|
|
|
|
|
|
|
const promise = createAjaxRequest({
|
|
|
|
const promise = createAjaxRequest({
|
|
|
|
url: '/command',
|
|
|
|
url: '/command',
|
|
|
|
method: 'POST',
|
|
|
|
method: 'POST',
|
|
|
|
data: JSON.stringify(payload),
|
|
|
|
data: JSON.stringify(requestPayload),
|
|
|
|
dataType: 'json'
|
|
|
|
dataType: 'json'
|
|
|
|
}).request;
|
|
|
|
}).request;
|
|
|
|
|
|
|
|
|
|
|
|
return promise.then((data) => {
|
|
|
|
return promise.then((data) => {
|
|
|
|
|
|
|
|
if (commandFinished) {
|
|
|
|
|
|
|
|
commandFinishedCallbacks[data.id] = commandFinished;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(addCommand(data));
|
|
|
|
dispatch(addCommand(data));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -183,12 +193,20 @@ export const actionHandlers = handleThunks({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const commandFinished = commandFinishedCallbacks[payload.id];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (commandFinished) {
|
|
|
|
|
|
|
|
commandFinished(payload);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete commandFinishedCallbacks[payload.id];
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(updateItem({ section: 'commands', ...payload }));
|
|
|
|
dispatch(updateItem({ section: 'commands', ...payload }));
|
|
|
|
scheduleRemoveCommand(payload, dispatch);
|
|
|
|
scheduleRemoveCommand(payload, dispatch);
|
|
|
|
showCommandMessage(payload, dispatch);
|
|
|
|
showCommandMessage(payload, dispatch);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
[ADD_COMMAND]: function(getState, payload, dispatch) {
|
|
|
|
[REMOVE_COMMAND]: function(getState, payload, dispatch) {
|
|
|
|
dispatch(removeItem({ section: 'commands', ...payload }));
|
|
|
|
dispatch(removeItem({ section: 'commands', ...payload }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|