110 lines
No EOL
3.6 KiB
JavaScript
110 lines
No EOL
3.6 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = _default;
|
|
|
|
var actions = _interopRequireWildcard(require("../constants/show_action_types"));
|
|
|
|
var _asset_display_states = require("../constants/asset_display_states");
|
|
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var initialState = {
|
|
request: {
|
|
error: null,
|
|
type: null,
|
|
id: null
|
|
},
|
|
requestList: {},
|
|
channelList: {},
|
|
assetList: {},
|
|
displayAsset: {
|
|
error: null,
|
|
status: _asset_display_states.LOCAL_CHECK
|
|
}
|
|
};
|
|
|
|
function _default() {
|
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
|
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
|
|
switch (action.type) {
|
|
// handle request
|
|
case actions.REQUEST_ERROR:
|
|
return Object.assign({}, state, {
|
|
request: Object.assign({}, state.request, {
|
|
error: action.data
|
|
})
|
|
});
|
|
|
|
case actions.REQUEST_UPDATE:
|
|
return Object.assign({}, state, {
|
|
request: Object.assign({}, state.request, {
|
|
type: action.data.requestType,
|
|
id: action.data.requestId
|
|
})
|
|
});
|
|
// store requests
|
|
|
|
case actions.REQUEST_LIST_ADD:
|
|
return Object.assign({}, state, {
|
|
requestList: Object.assign({}, state.requestList, _defineProperty({}, action.data.id, {
|
|
error: action.data.error,
|
|
key: action.data.key
|
|
}))
|
|
});
|
|
// asset data
|
|
|
|
case actions.ASSET_ADD:
|
|
return Object.assign({}, state, {
|
|
assetList: Object.assign({}, state.assetList, _defineProperty({}, action.data.id, {
|
|
error: action.data.error,
|
|
name: action.data.name,
|
|
claimId: action.data.claimId,
|
|
shortId: action.data.shortId,
|
|
claimData: action.data.claimData
|
|
}))
|
|
});
|
|
// channel data
|
|
|
|
case actions.CHANNEL_ADD:
|
|
return Object.assign({}, state, {
|
|
channelList: Object.assign({}, state.channelList, _defineProperty({}, action.data.id, {
|
|
name: action.data.name,
|
|
longId: action.data.longId,
|
|
shortId: action.data.shortId,
|
|
claimsData: action.data.claimsData
|
|
}))
|
|
});
|
|
|
|
case actions.CHANNEL_CLAIMS_UPDATE_SUCCESS:
|
|
return Object.assign({}, state, {
|
|
channelList: Object.assign({}, state.channelList, _defineProperty({}, action.data.channelListId, Object.assign({}, state.channelList[action.data.channelListId], {
|
|
claimsData: action.data.claimsData
|
|
})))
|
|
});
|
|
// 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: _asset_display_states.ERROR
|
|
})
|
|
});
|
|
|
|
default:
|
|
return state;
|
|
}
|
|
} |