diff --git a/client/coral-framework/actions/assets.js b/client/coral-framework/actions/assets.js index 226f1b2b9..5de9a86d5 100644 --- a/client/coral-framework/actions/assets.js +++ b/client/coral-framework/actions/assets.js @@ -1,5 +1,5 @@ import coralApi from '../helpers/response'; -import addItem from './items'; +import {addItem} from './items'; export const FETCH_MULTIPLE_ASSETS = 'FETCH_MULTIPLE_ASSETS'; export const RECEIVE_MULTIPLE_ASSETS = 'RECEIVE_MULTIPLE_ASSETS'; @@ -9,10 +9,10 @@ export const fetchMulitpleAssets = ids => { return dispatch => { dispatch({type: FETCH_MULTIPLE_ASSETS}); - coralApi(`/asset/multi?ids=${encodeURIComponent(ids.join(','))}`) + coralApi(`/assets/multi?ids=${encodeURIComponent(ids.join(','))}`) .then(assets => { - dispatch({type: RECEIVE_MULTIPLE_ASSETS, assets}); - console.log('assets!', assets); + assets.forEach(asset => dispatch(addItem(asset, 'assets'))); + dispatch({type: RECEIVE_MULTIPLE_ASSETS, assets: assets.map(asset => asset.id)}); }) .catch(error => dispatch({type: FAILURE_MULTIPLE_ASSSETS, error})); }; diff --git a/client/coral-framework/reducers/items.js b/client/coral-framework/reducers/items.js index 93388c1ab..268557809 100644 --- a/client/coral-framework/reducers/items.js +++ b/client/coral-framework/reducers/items.js @@ -6,6 +6,7 @@ import * as actions from '../actions/items'; const initialState = fromJS({ comments: {}, users: {}, + assets: {}, actions: {} }); diff --git a/client/coral-framework/reducers/user.js b/client/coral-framework/reducers/user.js index c7badf458..c4d061b42 100644 --- a/client/coral-framework/reducers/user.js +++ b/client/coral-framework/reducers/user.js @@ -1,12 +1,14 @@ import {Map, fromJS} from 'immutable'; import * as authActions from '../constants/auth'; import * as actions from '../constants/user'; +import * as assetActions from '../actions/assets'; const initialState = Map({ displayName: '', profiles: [], settings: {}, - myComments: [] + myComments: [], + myAssets: [] // the assets from which myComments (above) originated }); const purge = user => { @@ -33,6 +35,8 @@ export default function user (state = initialState, action) { .set('settings', action.settings); case actions.RECEIVE_COMMENTS_BY_USER: return state.set('myComments', fromJS(action.comments)); + case assetActions.RECEIVE_MULTIPLE_ASSETS: + return state.set('myAssets', fromJS(action.assets)); default : return state; } diff --git a/client/coral-plugin-history/Comment.js b/client/coral-plugin-history/Comment.js index a14320ecd..c7a1f5336 100644 --- a/client/coral-plugin-history/Comment.js +++ b/client/coral-plugin-history/Comment.js @@ -5,14 +5,19 @@ import styles from './Comment.css'; const Comment = props => { return (
); }; Comment.propTypes = { - comment: PropTypes.object.isRequired + comment: PropTypes.shape({ + body: PropTypes.string + }).isRequired, + asset: PropTypes.shape({ + url: PropTypes.string + }).isRequired }; export default Comment; diff --git a/client/coral-plugin-history/CommentHistory.js b/client/coral-plugin-history/CommentHistory.js index cdeaaf3cd..b937e87e9 100644 --- a/client/coral-plugin-history/CommentHistory.js +++ b/client/coral-plugin-history/CommentHistory.js @@ -7,15 +7,19 @@ const CommentHistory = props => {Loading comment history...
+ }