mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 17:45:56 +08:00
Asset reducers
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import {compose} from 'react-apollo';
|
||||
import {connect} from 'react-redux';
|
||||
import {isEqual} from 'lodash'
|
||||
|
||||
import {TabBar, Tab, TabContent, Spinner} from '../../coral-ui';
|
||||
|
||||
const {logout, showSignInDialog} = authActions;
|
||||
const {addNotification, clearNotification} = notificationActions;
|
||||
const {fetchAssetSuccess} = assetActions
|
||||
|
||||
import {queryStream} from './graphql/queries';
|
||||
import {postComment, postAction, deleteAction} from './graphql/mutations';
|
||||
import {Notification, notificationActions, authActions} from 'coral-framework';
|
||||
import {Notification, notificationActions, authActions, assetActions} from 'coral-framework';
|
||||
|
||||
import Stream from './Stream';
|
||||
import InfoBox from 'coral-plugin-infobox/InfoBox';
|
||||
@@ -49,10 +51,11 @@ class Embed extends Component {
|
||||
}
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
if (nextProps.data != null) {
|
||||
console.log(nextProps.data)
|
||||
const {loadAsset} = this.props
|
||||
if(!isEqual(nextProps.data.asset, this.props.data.asset)) {
|
||||
loadAsset(nextProps.data.asset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const {activeTab} = this.state;
|
||||
@@ -155,6 +158,7 @@ const mapStateToProps = state => ({
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
loadAsset: (asset) => dispatch(fetchAssetSuccess(asset)),
|
||||
addNotification: (type, text) => dispatch(addNotification(type, text)),
|
||||
clearNotification: () => dispatch(clearNotification()),
|
||||
showSignInDialog: (offset) => dispatch(showSignInDialog(offset)),
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import * as actions from '../constants/asset';
|
||||
|
||||
export const fetchAssetRequest = () => ({type: actions.FETCH_ASSET_REQUEST});
|
||||
export const fetchAssetSuccess = asset => ({type: actions.FETCH_ASSET_SUCCESS, asset});
|
||||
export const fetchAssetFailure = error => ({type: actions.FETCH_ASSET_FAILURE, error})
|
||||
@@ -5,6 +5,7 @@ import I18n from './modules/i18n/i18n';
|
||||
import * as notificationActions from './actions/notification';
|
||||
import * as authActions from './actions/auth';
|
||||
import * as configActions from './actions/config';
|
||||
import * as assetActions from './actions/asset';
|
||||
|
||||
export {
|
||||
Notification,
|
||||
@@ -13,5 +14,6 @@ export {
|
||||
I18n,
|
||||
notificationActions,
|
||||
authActions,
|
||||
configActions
|
||||
configActions,
|
||||
assetActions
|
||||
};
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import {Map} from 'immutable';
|
||||
import * as actions from '../constants/asset';
|
||||
|
||||
const initialState = Map({
|
||||
closedAt: null,
|
||||
settings: null,
|
||||
title: null,
|
||||
url: null
|
||||
});
|
||||
|
||||
export default function asset (state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case actions.FETCH_ASSET_SUCCESS :
|
||||
return state
|
||||
.merge(action.asset);
|
||||
default :
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import config from './config';
|
||||
import items from './items';
|
||||
import notification from './notification';
|
||||
import auth from './auth';
|
||||
import user from './user';
|
||||
import asset from './asset';
|
||||
import items from './items';
|
||||
import config from './config';
|
||||
import notification from './notification';
|
||||
|
||||
export default {
|
||||
auth,
|
||||
user,
|
||||
asset,
|
||||
items,
|
||||
config,
|
||||
notification
|
||||
|
||||
Reference in New Issue
Block a user