mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-03 12:27:30 -05:00
Fix project not available flag setting and catch 404 responses
This commit is contained in:
parent
315c8b78fc
commit
ae05f07e07
1 changed files with 3 additions and 3 deletions
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue