mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -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':
|
||||
return Object.assign({}, state, {
|
||||
projectInfo: action.info ? action.info : {},
|
||||
projectNotAvailable: !!action.info
|
||||
projectNotAvailable: !action.info
|
||||
});
|
||||
case 'SET_REMIXES':
|
||||
return Object.assign({}, state, {
|
||||
|
@ -311,13 +311,13 @@ module.exports.getProjectInfo = (id, token) => (dispatch => {
|
|||
Object.assign(opts, {authentication: token});
|
||||
}
|
||||
dispatch(module.exports.setFetchStatus('project', module.exports.Status.FETCHING));
|
||||
api(opts, (err, body) => {
|
||||
api(opts, (err, body, response) => {
|
||||
if (err) {
|
||||
dispatch(module.exports.setFetchStatus('project', module.exports.Status.ERROR));
|
||||
dispatch(module.exports.setError(err));
|
||||
return;
|
||||
}
|
||||
if (typeof body === 'undefined') {
|
||||
if (typeof body === 'undefined' || response.statusCode === 404) {
|
||||
dispatch(module.exports.setFetchStatus('project', module.exports.Status.ERROR));
|
||||
dispatch(module.exports.setError('No project info'));
|
||||
dispatch(module.exports.setProjectInfo(null));
|
||||
|
|
Loading…
Reference in a new issue