More tests.

This commit is contained in:
gaba
2016-12-12 15:38:28 -08:00
parent 83a7ffee6f
commit 0648b2b1c8
6 changed files with 74 additions and 20 deletions
+16 -2
View File
@@ -24,15 +24,29 @@ export const updateConfiguration = newConfig => (dispatch, getState) => {
.catch(error => dispatch(updateConfigFailure(error)));
};
export const updateOpenStream = newConfig => (dispatch, getState) => {
const assetId = getState().items.get('assets')
.keySeq()
.toArray()[0];
dispatch(updateConfigRequest());
coralApi(`/asset/${assetId}/status`, {method: 'PUT', body: newConfig})
.then(() => {
dispatch(addNotification('success', lang.t('successUpdateSettings')));
dispatch(updateConfigSuccess(newConfig));
})
.catch(error => dispatch(updateConfigFailure(error)));
};
const openStream = () => ({type: actions.OPEN_COMMENTS});
const closeStream = () => ({type: actions.CLOSE_COMMENTS});
export const updateOpenStatus = status => dispatch => {
if (status === 'open') {
dispatch(openStream());
dispatch(updateConfiguration({closedAt: null}));
dispatch(updateOpenStream({closedAt: null}));
} else {
dispatch(closeStream());
dispatch(updateConfiguration({closedAt: Date.getTime()}));
dispatch(updateOpenStream({closedAt: Date.now(), closedMessage: ''}));
}
};