2018-02-01 23:29:33 +01:00
|
|
|
import * as actions from 'constants/show_action_types';
|
2018-02-02 20:10:58 +01:00
|
|
|
import { CHANNEL, ASSET } from 'constants/show_request_types';
|
2018-02-07 04:00:52 +01:00
|
|
|
import { LOCAL_CHECK, ERROR } from 'constants/asset_display_states';
|
2018-02-01 23:29:33 +01:00
|
|
|
|
|
|
|
const initialState = {
|
2018-02-07 19:52:09 +01:00
|
|
|
request: {
|
|
|
|
error: null,
|
|
|
|
type : null,
|
|
|
|
},
|
2018-02-02 20:10:58 +01:00
|
|
|
channelRequest: {
|
|
|
|
name: null,
|
|
|
|
id : null,
|
2018-02-01 23:29:33 +01:00
|
|
|
},
|
2018-02-02 20:10:58 +01:00
|
|
|
assetRequest: {
|
|
|
|
name : null,
|
|
|
|
modifier: {
|
|
|
|
id : null,
|
|
|
|
channel: {
|
|
|
|
name: null,
|
|
|
|
id : null,
|
|
|
|
},
|
2018-02-02 03:42:03 +01:00
|
|
|
},
|
2018-02-02 20:10:58 +01:00
|
|
|
extension: null,
|
2018-02-01 23:29:33 +01:00
|
|
|
},
|
2018-02-03 03:16:18 +01:00
|
|
|
showChannel: {
|
2018-02-07 20:30:39 +01:00
|
|
|
error : null,
|
2018-02-03 03:16:18 +01:00
|
|
|
channelData: {
|
|
|
|
name : null,
|
|
|
|
shortId: null,
|
|
|
|
longId : null,
|
|
|
|
},
|
|
|
|
channelClaimsData: {
|
|
|
|
claims : null,
|
|
|
|
currentPage: null,
|
|
|
|
totalPages : null,
|
|
|
|
totalClaims: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
showAsset: {
|
2018-02-07 04:00:52 +01:00
|
|
|
error : null,
|
|
|
|
claimData: null,
|
|
|
|
shortId : null,
|
2018-02-03 03:16:18 +01:00
|
|
|
},
|
2018-02-07 19:52:09 +01:00
|
|
|
displayAsset: {
|
|
|
|
error : null,
|
|
|
|
status: LOCAL_CHECK,
|
|
|
|
},
|
2018-02-07 22:26:07 +01:00
|
|
|
channelRequests: {},
|
|
|
|
assetRequests : {},
|
|
|
|
channels : {},
|
|
|
|
assets : {},
|
2018-02-01 23:29:33 +01:00
|
|
|
};
|
|
|
|
|
2018-02-07 22:26:07 +01:00
|
|
|
/* asset request schema:
|
|
|
|
name#someidfrommodifier: {
|
|
|
|
error : null
|
|
|
|
claimId: null,
|
|
|
|
} */
|
|
|
|
|
|
|
|
/* asset schema:
|
|
|
|
name#claimId: {
|
|
|
|
error : null,
|
|
|
|
name : null,
|
|
|
|
claimId : null,
|
|
|
|
claimData: null,
|
|
|
|
shortId : null,
|
|
|
|
display : {
|
|
|
|
error : null,
|
|
|
|
status: null,
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
|
2018-02-01 23:29:33 +01:00
|
|
|
/*
|
|
|
|
Reducers describe how the application's state changes in response to actions
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default function (state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2018-02-07 20:30:39 +01:00
|
|
|
// request cases
|
|
|
|
case actions.REQUEST_ERROR_UPDATE:
|
2018-02-01 23:29:33 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-07 19:52:09 +01:00
|
|
|
request: Object.assign({}, state.request, {
|
2018-02-07 20:30:39 +01:00
|
|
|
error: action.data,
|
2018-02-07 19:52:09 +01:00
|
|
|
}),
|
2018-02-07 20:30:39 +01:00
|
|
|
});
|
|
|
|
case actions.REQUEST_CHANNEL_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
request: {
|
|
|
|
type : CHANNEL,
|
|
|
|
error: null,
|
|
|
|
},
|
2018-02-06 20:55:46 +01:00
|
|
|
channelRequest: action.data,
|
2018-02-01 23:29:33 +01:00
|
|
|
});
|
2018-02-07 19:52:09 +01:00
|
|
|
case actions.REQUEST_CLAIM_UPDATE:
|
2018-02-01 23:29:33 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-07 20:30:39 +01:00
|
|
|
request: {
|
|
|
|
type : ASSET,
|
|
|
|
error: null,
|
|
|
|
},
|
2018-02-06 20:55:46 +01:00
|
|
|
assetRequest: action.data,
|
2018-02-01 23:29:33 +01:00
|
|
|
});
|
2018-02-07 20:30:39 +01:00
|
|
|
// show channel cases
|
|
|
|
case actions.SHOW_CHANNEL_ERROR:
|
2018-02-07 19:52:09 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-07 20:36:13 +01:00
|
|
|
showChannel: Object.assign({}, state.showChannel, {
|
2018-02-07 19:52:09 +01:00
|
|
|
error: action.data,
|
|
|
|
}),
|
|
|
|
});
|
2018-02-03 03:16:18 +01:00
|
|
|
case actions.CHANNEL_DATA_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
showChannel: Object.assign({}, state.showChannel, {
|
2018-02-06 20:55:46 +01:00
|
|
|
channelData: action.data,
|
2018-02-03 03:16:18 +01:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
case actions.CHANNEL_CLAIMS_DATA_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
showChannel: Object.assign({}, state.showChannel, {
|
2018-02-06 20:55:46 +01:00
|
|
|
channelClaimsData: action.data,
|
2018-02-03 03:16:18 +01:00
|
|
|
}),
|
|
|
|
});
|
2018-02-07 20:30:39 +01:00
|
|
|
// show asset cases
|
|
|
|
case actions.SHOW_ASSET_ERROR:
|
2018-02-03 03:16:18 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-07 04:00:52 +01:00
|
|
|
showAsset: Object.assign({}, state.showAsset, {
|
2018-02-07 20:30:39 +01:00
|
|
|
error: action.data,
|
2018-02-07 04:00:52 +01:00
|
|
|
}),
|
|
|
|
});
|
2018-02-07 20:30:39 +01:00
|
|
|
case actions.ASSET_CLAIM_DATA_UPDATE:
|
2018-02-07 04:00:52 +01:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
showAsset: Object.assign({}, state.showAsset, {
|
2018-02-07 20:30:39 +01:00
|
|
|
claimData: action.data.data,
|
|
|
|
shortId : action.data.shortId,
|
2018-02-07 19:52:09 +01:00
|
|
|
}),
|
|
|
|
});
|
2018-02-07 20:30:39 +01:00
|
|
|
// display asset cases
|
2018-02-07 19:52:09 +01:00
|
|
|
case actions.FILE_AVAILABILITY_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
displayAsset: Object.assign({}, state.displayAsset, {
|
2018-02-07 04:00:52 +01:00
|
|
|
status: action.data,
|
|
|
|
}),
|
|
|
|
});
|
2018-02-07 19:52:09 +01:00
|
|
|
case actions.DISPLAY_ASSET_ERROR:
|
2018-02-07 04:00:52 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-07 19:52:09 +01:00
|
|
|
displayAsset: Object.assign({}, state.displayAsset, {
|
2018-02-07 04:00:52 +01:00
|
|
|
error : action.data,
|
|
|
|
status: ERROR,
|
|
|
|
}),
|
2018-02-03 03:16:18 +01:00
|
|
|
});
|
2018-02-07 22:26:07 +01:00
|
|
|
// new actions
|
|
|
|
case actions.ASSET_REQUEST_ADD:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
assetRequests: Object.assign({}, state.assets, {
|
|
|
|
[action.data.id]: {
|
|
|
|
error : action.data.error,
|
|
|
|
claimId: action.data.claimId,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
// case actions.ASSET_ADD:
|
|
|
|
// return Object.assign({}, state, {
|
|
|
|
// assets: Object.assign({}, state.assets, {
|
|
|
|
// [`${action.data.name}#${action.data.claimId}`]: action.data,
|
|
|
|
// }),
|
|
|
|
// });
|
2018-02-01 23:29:33 +01:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|