2018-02-01 23:29:33 +01:00
|
|
|
import * as actions from 'constants/show_action_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: {
|
2018-02-14 20:39:24 +01:00
|
|
|
error: null,
|
|
|
|
type : null,
|
|
|
|
id : null,
|
2018-02-01 23:29:33 +01:00
|
|
|
},
|
2018-02-15 03:02:10 +01:00
|
|
|
requestList : {},
|
|
|
|
channelList : {},
|
|
|
|
assetList : {},
|
|
|
|
displayAsset: {
|
2018-02-14 01:51:59 +01:00
|
|
|
error : null,
|
|
|
|
status: LOCAL_CHECK,
|
|
|
|
},
|
2018-02-01 23:29:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function (state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2018-02-08 03:41:22 +01:00
|
|
|
// handle request
|
2018-02-23 00:43:26 +01:00
|
|
|
case actions.REQUEST_ERROR:
|
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
|
|
|
});
|
2018-02-23 00:43:26 +01:00
|
|
|
case actions.REQUEST_UPDATE:
|
2018-02-07 20:30:39 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-14 20:39:24 +01:00
|
|
|
request: Object.assign({}, state.request, {
|
|
|
|
type: action.data.requestType,
|
|
|
|
id : action.data.requestId,
|
|
|
|
}),
|
2018-02-01 23:29:33 +01:00
|
|
|
});
|
2018-02-14 21:09:57 +01:00
|
|
|
// store requests
|
2018-02-15 02:26:11 +01:00
|
|
|
case actions.REQUEST_LIST_ADD:
|
2018-02-07 22:26:07 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-14 21:19:43 +01:00
|
|
|
requestList: Object.assign({}, state.requestList, {
|
2018-02-07 22:26:07 +01:00
|
|
|
[action.data.id]: {
|
2018-02-14 21:09:57 +01:00
|
|
|
error: action.data.error,
|
|
|
|
key : action.data.key,
|
2018-02-07 22:26:07 +01:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
2018-02-14 21:09:57 +01:00
|
|
|
// asset data
|
2018-02-14 02:16:50 +01:00
|
|
|
case actions.ASSET_ADD:
|
2018-02-08 19:59:49 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-02-13 05:01:02 +01:00
|
|
|
assetList: Object.assign({}, state.assetList, {
|
|
|
|
[action.data.id]: {
|
|
|
|
error : action.data.error,
|
|
|
|
name : action.data.name,
|
|
|
|
claimId : action.data.claimId,
|
|
|
|
shortId : action.data.shortId,
|
|
|
|
claimData: action.data.claimData,
|
|
|
|
},
|
|
|
|
}),
|
2018-02-08 07:22:17 +01:00
|
|
|
});
|
2018-02-14 21:09:57 +01:00
|
|
|
// channel data
|
2018-02-14 02:16:50 +01:00
|
|
|
case actions.CHANNEL_ADD:
|
2018-02-08 19:59:49 +01:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
channelList: Object.assign({}, state.channelList, {
|
|
|
|
[action.data.id]: {
|
2018-02-13 03:18:56 +01:00
|
|
|
name : action.data.name,
|
|
|
|
longId : action.data.longId,
|
|
|
|
shortId : action.data.shortId,
|
|
|
|
claimsData: action.data.claimsData,
|
2018-02-08 19:59:49 +01:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
2018-02-13 05:01:02 +01:00
|
|
|
case actions.CHANNEL_CLAIMS_UPDATE_SUCCESS:
|
2018-02-09 19:02:13 +01:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
channelList: Object.assign({}, state.channelList, {
|
|
|
|
[action.data.channelListId]: Object.assign({}, state.channelList[action.data.channelListId], {
|
|
|
|
claimsData: action.data.claimsData,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
});
|
2018-02-08 03:41:22 +01:00
|
|
|
// display an asset
|
|
|
|
case actions.FILE_AVAILABILITY_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
displayAsset: Object.assign({}, state.displayAsset, {
|
|
|
|
status: action.data,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
case actions.DISPLAY_ASSET_ERROR:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
displayAsset: Object.assign({}, state.displayAsset, {
|
|
|
|
error : action.data,
|
|
|
|
status: ERROR,
|
|
|
|
}),
|
|
|
|
});
|
2018-02-01 23:29:33 +01:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|