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