Authored by 王钱钧

完善消息中心模块功能。code review by 于良

... ... @@ -20,7 +20,6 @@ export default class MessageIcon extends React.Component {
isRedDot: React.PropTypes.bool,
defaultSource: React.PropTypes.string,
image:React.PropTypes.string,
iconTap: React.PropTypes.func,
}
... ... @@ -47,7 +46,7 @@ export default class MessageIcon extends React.Component {
return (
<View style={[styles.container, this.props.extraStyle]}>
<TouchableOpacity activeOpacity={0.8} onPress={() => {
this.props.iconTap && this.props.iconTap();
this.props.iconTap && this.props.iconTap(this.props.extra);
}}>
<SlicedImage
... ...
... ... @@ -53,11 +53,12 @@ export default class MessageCenter extends React.Component {
),
onPressSystemMsg: React.PropTypes.func,
onPressLike: React.PropTypes.func,
onPressAvatar: React.PropTypes.func,
onPressSection: React.PropTypes.func,
onRefresh: React.PropTypes.func,
onPressSystemCell: React.PropTypes.func,
onPressLikeCell: React.PropTypes.func,
onPressPost: React.PropTypes.func,
};
constructor(props) {
... ... @@ -116,6 +117,9 @@ export default class MessageCenter extends React.Component {
}
return (
<MsgCenterNormalCell
onPressAvatar={this.props.onPressAvatar}
onPressSection={this.props.onPressSection}
onPressPost={this.props.onPressPost}
data={rowData}
/>
);
... ...
... ... @@ -35,6 +35,7 @@ export default class MsgCenterNormalCell extends React.Component {
onPressPost: React.PropTypes.func,
onPressAvatar: React.PropTypes.func,
onPressSection: React.PropTypes.func,
};
constructor(props) {
... ... @@ -44,12 +45,22 @@ export default class MsgCenterNormalCell extends React.Component {
render() {
let data = this.props.data.toJS();
let {user, title, timeago, post, subTitle} = data;
let section = post.sectionId;
let postId = post.id;
return (
<TouchableOpacity
activeOpacity={0.8}
onPress={() => {
this.props.onPressPost && this.props.onPressPost(postId);
}}
>
<View style={styles.container}>
<View style={styles.topContainer}>
<LittleRedDotImage
extra = {user.id}
iconTap={this.props.onPressAvatar}
isRedDot={true}
image={user.avatar}
/>
... ... @@ -80,7 +91,7 @@ export default class MsgCenterNormalCell extends React.Component {
<SectionItem
name={post.sectionName}
onPressSection={() => {
this.props.onPressSectionTag && this.props.onPressSectionTag();
this.props.onPressSection && this.props.onPressSection(section);
}}
/>
</View>
... ... @@ -88,7 +99,7 @@ export default class MsgCenterNormalCell extends React.Component {
</View>
</View>
</TouchableOpacity>
);
}
... ...
... ... @@ -37,6 +37,7 @@ export default class ReplyCell extends React.Component {
onPressPost: React.PropTypes.func,
onPressAvatar: React.PropTypes.func,
onPressSection: React.PropTypes.func,
};
... ... @@ -47,8 +48,16 @@ export default class ReplyCell extends React.Component {
render() {
let data = this.props.data.toJS();
let {user, title, timeago, post, subTitle} = data;
let postId = post.id;
let section = post.sectionId;
return (
<TouchableOpacity
activeOpacity={0.8}
onPress={() => {
this.props.onPressPost && this.props.onPressPost(postId);
}}
>
<View style={styles.container}>
<View style={styles.topContainer}>
<View style={styles.topRight}>
... ... @@ -80,7 +89,7 @@ export default class ReplyCell extends React.Component {
<SectionItem
name={post.sectionName}
onPressSection={() => {
this.props.onPressSectionTag && this.props.onPressSectionTag();
this.props.onPressSection && this.props.onPressSection(section);
}}
/>
</View>
... ... @@ -89,6 +98,8 @@ export default class ReplyCell extends React.Component {
</View>
</TouchableOpacity>
);
... ...
... ... @@ -67,6 +67,8 @@ export default class SystemMessage extends React.Component {
return (
<SysMsgCell
data={rowData}
onPressSection={this.props.onPressSection}
onPressPost={this.props.onPressPost}
/>
);
}
... ...
... ... @@ -9,8 +9,9 @@ import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import MessageCenter from '../components/message/MessageCenter';
import * as homeActions from '../reducers/home/homeActions';
import * as messageActions from '../reducers/message/messageActions';
import * as userThatNotMeActions from '../reducers/userThatNotMe/userThatNotMeActions';
const {
Text,
... ... @@ -23,6 +24,8 @@ const {
const actions = [
messageActions,
userThatNotMeActions,
homeActions,
];
function mapStateToProps(state) {
... ... @@ -47,8 +50,9 @@ class MessageCenterContainer extends React.Component {
constructor(props) {
super(props);
this._onPressAvatar = this._onPressAvatar.bind(this);
this._onPressSystemMsg = this._onPressSystemMsg.bind(this);
this._onPressLike = this._onPressLike.bind(this);
this._onPressPost = this._onPressPost.bind(this);
this._onPressSection = this._onPressSection.bind(this);
this._onRefresh = this._onRefresh.bind(this);
this._onEndReached = this._onEndReached.bind(this);
... ... @@ -57,18 +61,24 @@ class MessageCenterContainer extends React.Component {
}
_onPressLike() {
console.log('on press like');
_onPressAvatar(uid) {
console.log('avatar');
this.props.actions.goToUserNotMe(uid);
}
_onPressPost(id) {
console.log('post id = ' + id);
if (id) {
this.props.actions.goToPost(id);
}
}
_onPressSystemMsg() {
console.log('on press system message');
}
_onPressSection(id) {
console.log('section id =' + id);
// this.props.actions.goToPost(id);
_onPressSection(section) {
this.props.actions.goToSection(section, this.props.navigationState.name);
}
_onRefresh() {
... ... @@ -105,18 +115,19 @@ class MessageCenterContainer extends React.Component {
return (
<View style={styles.container}>
<MessageCenter
sysMsg={Immutable.fromJS([sysMsg])}
likeMsg={Immutable.fromJS([likeMsg])}
ptr={ptr}
list={list}
onRefresh={this._onRefresh}
onPressSystemMsg={this._onPressSystemMsg}
onPressLike={this._onPressLike}
onPressSection={this._onPressSection}
isFetching={isFetching}
ptr={ptr}
endReached={endReached}
isRefreshing={isRefreshing}
isLoadingMore={isLoadingMore}
sysMsg={Immutable.fromJS([sysMsg])}
likeMsg={Immutable.fromJS([likeMsg])}
onPressPost={this._onPressPost}
onRefresh={this._onRefresh}
onPressSystemMsg={this._onPressSystemMsg}
onPressAvatar={this._onPressAvatar}
onPressSection={this._onPressSection}
onPressSystemCell={this._onPressSystemCell}
onPressLikeCell={this._onPressLikeCell}
/>
... ...
... ... @@ -10,6 +10,7 @@ import {connect} from 'react-redux';
import SystemMessage from '../components/message/SystemMessage';
import * as messageActions from '../reducers/message/messageActions';
import * as homeActions from '../reducers/home/homeActions';
const {
Text,
... ... @@ -22,6 +23,7 @@ const {
const actions = [
messageActions,
homeActions,
];
function mapStateToProps(state) {
... ... @@ -49,16 +51,24 @@ class SystemMessageContainer extends React.Component {
this._onPressSection = this._onPressSection.bind(this);
this._onRefresh = this._onRefresh.bind(this);
this._onEndReached = this._onEndReached.bind(this);
this._onPressPost = this._onPressPost.bind(this);
this._onPressSection = this._onPressSection.bind(this);
}
componentDidMount() {
this._onEndReached();
}
_onPressPost(id) {
console.log('post id = ' + id);
if (id) {
this.props.actions.goToPost(id);
}
}
_onPressSection(id) {
console.log('_onPressSection id =' + id);
// this.props.actions.goToPost(id);
this.props.actions.goToSection(section, this.props.navigationState.name);
}
... ... @@ -94,6 +104,7 @@ class SystemMessageContainer extends React.Component {
onRefresh={this._onRefresh}
onPressSection={this._onPressSection}
onEndReached={this._onEndReached}
onPressPost={this._onPressPost}
/>
</View>
);
... ...
... ... @@ -35,6 +35,24 @@ export function goToUserOrMe(uid) {
};
}
export function goToUserNotMe(uid) {
console.log('uid =========== ' + uid);
return (dispatch, getState) => {
let {user} = getState();
if (user.profile.uid == uid) {
// Actions.User();
} else {
Actions.UserThatNotMe();
}
// dispatch({
// type: GO_TO_USER_OR_ME,
// payload: uid,
// });
};
}
export function userThatNotMeInfoRequest(sid) {
return {
type: USER_TNM_INFO_REQUEST,
... ...