From ca4311450d65bcc315433288a2996311891a7b21 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 6 Feb 2018 12:11:44 -0800 Subject: [PATCH] fixed other actions to use data object --- react/actions/channel.js | 8 +++++--- react/actions/publish.js | 30 ++++++++++++++++++------------ react/reducers/channel.js | 6 +----- react/reducers/publish.js | 17 +++++++---------- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/react/actions/channel.js b/react/actions/channel.js index a1e34e71..7c17ed94 100644 --- a/react/actions/channel.js +++ b/react/actions/channel.js @@ -5,8 +5,10 @@ import * as actions from 'constants/channel_action_types'; export function updateLoggedInChannel (name, shortId, longId) { return { type: actions.CHANNEL_UPDATE, - name, - shortId, - longId, + data: { + name, + shortId, + longId, + }, }; }; diff --git a/react/actions/publish.js b/react/actions/publish.js index 603aca4e..8afd3556 100644 --- a/react/actions/publish.js +++ b/react/actions/publish.js @@ -4,7 +4,7 @@ import * as actions from 'constants/publish_action_types'; export function selectFile (file) { return { type: actions.FILE_SELECTED, - file: file, + data: file, }; }; @@ -17,15 +17,17 @@ export function clearFile () { export function updateMetadata (name, value) { return { type: actions.METADATA_UPDATE, - name, - value, + data: { + name, + value, + }, }; }; export function updateClaim (value) { return { type: actions.CLAIM_UPDATE, - value, + data: value, }; }; @@ -39,29 +41,33 @@ export function setPublishInChannel (channel) { export function updatePublishStatus (status, message) { return { type: actions.PUBLISH_STATUS_UPDATE, - status, - message, + data: { + status, + message, + }, }; }; export function updateError (name, value) { return { type: actions.ERROR_UPDATE, - name, - value, + data: { + name, + value, + }, }; }; -export function updateSelectedChannel (value) { +export function updateSelectedChannel (channelName) { return { type: actions.SELECTED_CHANNEL_UPDATE, - value, + data: channelName, }; }; -export function toggleMetadataInputs (value) { +export function toggleMetadataInputs (showMetadataInputs) { return { type: actions.TOGGLE_METADATA_INPUTS, - value, + data: showMetadataInputs, }; }; diff --git a/react/reducers/channel.js b/react/reducers/channel.js index fcf1f33c..30dd0166 100644 --- a/react/reducers/channel.js +++ b/react/reducers/channel.js @@ -16,11 +16,7 @@ export default function (state = initialState, action) { switch (action.type) { case actions.CHANNEL_UPDATE: return Object.assign({}, state, { - loggedInChannel: { - name : action.name, - shortId: action.shortId, - longId : action.longId, - }, + loggedInChannel: action.data, }); default: return state; diff --git a/react/reducers/publish.js b/react/reducers/publish.js index 1195a37d..e964fcec 100644 --- a/react/reducers/publish.js +++ b/react/reducers/publish.js @@ -34,19 +34,19 @@ export default function (state = initialState, action) { switch (action.type) { case actions.FILE_SELECTED: return Object.assign({}, state, { - file: action.file, + file: action.data, }); case actions.FILE_CLEAR: return initialState; case actions.METADATA_UPDATE: return Object.assign({}, state, { metadata: Object.assign({}, state.metadata, { - [action.name]: action.value, + [action.data.name]: action.data.value, }), }); case actions.CLAIM_UPDATE: return Object.assign({}, state, { - claim: action.value, + claim: action.data, }); case actions.SET_PUBLISH_IN_CHANNEL: return Object.assign({}, state, { @@ -54,24 +54,21 @@ export default function (state = initialState, action) { }); case actions.PUBLISH_STATUS_UPDATE: return Object.assign({}, state, { - status: Object.assign({}, state.status, { - status : action.status, - message: action.message, - }), + status: action.data, }); case actions.ERROR_UPDATE: return Object.assign({}, state, { error: Object.assign({}, state.error, { - [action.name]: action.value, + [action.data.name]: action.data.value, }), }); case actions.SELECTED_CHANNEL_UPDATE: return Object.assign({}, state, { - selectedChannel: action.value, + selectedChannel: action.data, }); case actions.TOGGLE_METADATA_INPUTS: return Object.assign({}, state, { - showMetadataInputs: action.value, + showMetadataInputs: action.data, }); default: return state;