Fix project not available flag setting and catch 404 responses

This commit is contained in:
Paul Kaplan 2018-11-08 08:43:36 -05:00
parent 315c8b78fc
commit ae05f07e07

View file

@ -53,7 +53,7 @@ module.exports.previewReducer = (state, action) => {
case 'SET_PROJECT_INFO': case 'SET_PROJECT_INFO':
return Object.assign({}, state, { return Object.assign({}, state, {
projectInfo: action.info ? action.info : {}, projectInfo: action.info ? action.info : {},
projectNotAvailable: !!action.info projectNotAvailable: !action.info
}); });
case 'SET_REMIXES': case 'SET_REMIXES':
return Object.assign({}, state, { return Object.assign({}, state, {
@ -311,13 +311,13 @@ module.exports.getProjectInfo = (id, token) => (dispatch => {
Object.assign(opts, {authentication: token}); Object.assign(opts, {authentication: token});
} }
dispatch(module.exports.setFetchStatus('project', module.exports.Status.FETCHING)); dispatch(module.exports.setFetchStatus('project', module.exports.Status.FETCHING));
api(opts, (err, body) => { api(opts, (err, body, response) => {
if (err) { if (err) {
dispatch(module.exports.setFetchStatus('project', module.exports.Status.ERROR)); dispatch(module.exports.setFetchStatus('project', module.exports.Status.ERROR));
dispatch(module.exports.setError(err)); dispatch(module.exports.setError(err));
return; return;
} }
if (typeof body === 'undefined') { if (typeof body === 'undefined' || response.statusCode === 404) {
dispatch(module.exports.setFetchStatus('project', module.exports.Status.ERROR)); dispatch(module.exports.setFetchStatus('project', module.exports.Status.ERROR));
dispatch(module.exports.setError('No project info')); dispatch(module.exports.setError('No project info'));
dispatch(module.exports.setProjectInfo(null)); dispatch(module.exports.setProjectInfo(null));