spee.ch/client/actions/show.js

120 lines
2.6 KiB
JavaScript
Raw Normal View History

import * as actions from 'constants/show_action_types';
import { CHANNEL, ASSET_LITE, ASSET_DETAILS } from 'constants/show_request_types';
2018-02-08 03:41:22 +01:00
// basic request parsing
export function onHandleShowPageUri (params) {
return {
type: actions.HANDLE_SHOW_URI,
data: params,
};
};
export function onRequestError (error) {
return {
type: actions.REQUEST_ERROR,
data: error,
};
};
export function onNewChannelRequest (channelName, channelId) {
const requestType = CHANNEL;
const requestId = `cr#${channelName}#${channelId}`;
return {
type: actions.CHANNEL_REQUEST_NEW,
data: { requestType, requestId, channelName, channelId },
};
};
export function onNewAssetRequest (name, id, channelName, channelId, extension) {
const requestType = extension ? ASSET_LITE : ASSET_DETAILS;
2018-02-08 05:15:44 +01:00
const requestId = `ar#${name}#${id}#${channelName}#${channelId}`;
return {
type: actions.ASSET_REQUEST_NEW,
2018-02-06 20:55:46 +01:00
data: {
requestType,
2018-02-08 05:15:44 +01:00
requestId,
2018-02-06 20:55:46 +01:00
name,
modifier: {
id,
channel: {
name: channelName,
id : channelId,
},
},
},
};
};
2018-02-03 03:16:18 +01:00
export function onRequestUpdate (requestType, requestId) {
return {
type: actions.REQUEST_UPDATE,
data: {
requestType,
requestId,
},
};
};
export function addRequestToRequestList (id, error, key) {
2018-02-03 03:16:18 +01:00
return {
type: actions.REQUEST_LIST_ADD,
2018-02-14 21:09:57 +01:00
data: { id, error, key },
2018-02-03 03:16:18 +01:00
};
};
2018-02-14 21:09:57 +01:00
// asset actions
export function addAssetToAssetList (id, error, name, claimId, shortId, claimData) {
return {
2018-02-14 02:16:50 +01:00
type: actions.ASSET_ADD,
data: { id, error, name, claimId, shortId, claimData },
};
}
2018-02-14 02:16:50 +01:00
// channel actions
2018-02-08 03:41:22 +01:00
export function addNewChannelToChannelList (id, name, shortId, longId, claimsData) {
2018-02-08 07:22:17 +01:00
return {
2018-02-14 02:16:50 +01:00
type: actions.CHANNEL_ADD,
data: { id, name, shortId, longId, claimsData },
2018-02-08 07:22:17 +01:00
};
};
2018-02-07 22:26:07 +01:00
export function onUpdateChannelClaims (channelKey, name, longId, page) {
return {
2018-02-13 05:01:02 +01:00
type: actions.CHANNEL_CLAIMS_UPDATE_ASYNC,
data: {channelKey, name, longId, page},
};
};
export function updateChannelClaims (channelListId, claimsData) {
return {
2018-02-13 05:01:02 +01:00
type: actions.CHANNEL_CLAIMS_UPDATE_SUCCESS,
data: {channelListId, claimsData},
};
};
2018-02-09 00:47:10 +01:00
2018-02-08 03:41:22 +01:00
// display a file
2018-02-08 03:41:22 +01:00
export function fileRequested (name, claimId) {
return {
2018-02-08 03:41:22 +01:00
type: actions.FILE_REQUESTED,
data: { name, claimId },
};
};
2018-02-08 03:41:22 +01:00
export function updateFileAvailability (status) {
return {
2018-02-08 03:41:22 +01:00
type: actions.FILE_AVAILABILITY_UPDATE,
data: status,
};
};
2018-02-08 03:41:22 +01:00
export function updateDisplayAssetError (error) {
return {
2018-02-08 03:41:22 +01:00
type: actions.DISPLAY_ASSET_ERROR,
data: error,
};
};