Authored by 于良

优化回调方法调用 review by 盖剑秋

... ... @@ -170,11 +170,12 @@ export default function community(platform) {
rightButtonImage={rightImage}
onRight={this.homeOnRight}
renderTitle={this.contanerIsYohoBuy() ? this.renderHomeTitle : null}
getPostingState={
() => {
getPostingState={() => {
return store.getState().posting.inPosting;
}
}
}}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -206,6 +207,9 @@ export default function community(platform) {
hideNavBar={true}
component={UserContainer}
initial={false}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
... ... @@ -242,6 +246,9 @@ export default function community(platform) {
clone={true}
component={UserThatNotMeContainer}
initial={false}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
... ...
... ... @@ -64,21 +64,11 @@ export default class CommunityList extends React.Component {
<ListCell
key={sectionID + rowID}
data={rowData}
onPressPost={() => {
this.props.onPressPost && this.props.onPressPost(rowData.get('id'));
}}
onPressAvatar={(url) => {
this.props.onPressAvatar && this.props.onPressAvatar(url);
}}
onPressSectionTag={() => {
this.props.onPressSectionTag && this.props.onPressSectionTag(rowData.get('section').toJS());
}}
onPressComment={() => {
this.props.onPressComment && this.props.onPressComment(rowData.get('id'));
}}
onPressLike={() => {
this.props.onPressLike && this.props.onPressLike(rowData);
}}
onPressPost={this.props.onPressPost}
onPressAvatar={this.props.onPressAvatar}
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
/>
);
}
... ... @@ -99,6 +89,7 @@ export default class CommunityList extends React.Component {
renderSeparator={this._renderSeparator}
enableEmptySections={true}
scrollEnabled={false}
onEndReached={() => {}}
/>
);
... ...
... ... @@ -180,9 +180,7 @@ export default class Home extends React.Component {
duration={this.props.bannerDuration}
width={width}
height={bannerHeight}
onPress={(url) => {
this.props.onPressBanner && this.props.onPressBanner(url);
}}
onPress={this.props.onPressBanner}
/>
);
}
... ... @@ -193,9 +191,7 @@ export default class Home extends React.Component {
duration={this.props.noticeDuration}
width={width}
height={40}
onPress={(url) => {
this.props.onPressNotice && this.props.onPressNotice(url);
}}
onPress={this.props.onPressNotice}
/>
);
case 'section':
... ... @@ -218,21 +214,11 @@ export default class Home extends React.Component {
<ListCell
key={sectionID + rowID}
data={rowData}
onPressPost={() => {
this.props.onPressPost && this.props.onPressPost(rowData.get('id'));
}}
onPressAvatar={() => {
this.props.onPressAvatar && this.props.onPressAvatar(rowData.get('author').get('uid'));
}}
onPressSectionTag={() => {
this.props.onPressSectionTag && this.props.onPressSectionTag(rowData.get('section').toJS());
}}
onPressComment={() => {
this.props.onPressComment && this.props.onPressComment(rowData.get('id'));
}}
onPressLike={() => {
this.props.onPressLike && this.props.onPressLike(rowData);
}}
onPressPost={this.props.onPressPost}
onPressAvatar={this.props.onPressAvatar}
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
/>
);
}
... ...
... ... @@ -30,6 +30,7 @@ export default class ListCell extends React.Component {
isOwner: React.PropTypes.bool,
isTop: React.PropTypes.bool,
isLike: React.PropTypes.bool,
id: React.PropTypes.number,
title: React.PropTypes.string,
desc: React.PropTypes.string,
thumbs: ImmutablePropTypes.listOf(
... ... @@ -58,7 +59,7 @@ export default class ListCell extends React.Component {
render() {
let data = this.props.data.toJS();
let {author, timeago, isOwner, isTop, isLike, title, desc, thumbs, section, commentCount, likeCount} = data;
let {author, timeago, isOwner, isTop, isLike, id, title, desc, thumbs, section, commentCount, likeCount} = data;
let likeImage = isLike ? require('../../images/home/like.png') : require('../../images/home/unlike.png');
return (
... ... @@ -66,10 +67,9 @@ export default class ListCell extends React.Component {
style={styles.row}
activeOpacity={0.8}
onPress={() => {
this.props.onPressPost && this.props.onPressPost();
this.props.onPressPost && this.props.onPressPost(id);
}}
>
<View style={styles.top}>
<UserBrief
avatar={author.avatar}
... ... @@ -77,7 +77,7 @@ export default class ListCell extends React.Component {
timeago={timeago}
isOwner={isOwner}
onPressAvatar={() => {
this.props.onPressAvatar && this.props.onPressAvatar();
this.props.onPressAvatar && this.props.onPressAvatar(author.uid);
}}
/>
{isTop ? <Text style={styles.topTag}>置顶</Text> : null}
... ... @@ -89,7 +89,7 @@ export default class ListCell extends React.Component {
<SectionItem
name={section.name}
onPressSection={() => {
this.props.onPressSectionTag && this.props.onPressSectionTag();
this.props.onPressSectionTag && this.props.onPressSectionTag(section);
}}
/>
<View style={styles.buttonContainer}>
... ... @@ -97,7 +97,7 @@ export default class ListCell extends React.Component {
source={require('../../images/home/mes.png')}
number={commentCount}
onPressButton={() => {
this.props.onPressComment && this.props.onPressComment();
this.props.onPressComment && this.props.onPressComment(id);
}}
/>
<NumberButton
... ... @@ -105,7 +105,7 @@ export default class ListCell extends React.Component {
source={likeImage}
number={likeCount}
onPressButton={() => {
this.props.onPressLike && this.props.onPressLike();
this.props.onPressLike && this.props.onPressLike(data);
}}
/>
</View>
... ...
... ... @@ -179,9 +179,7 @@ export default class Section extends React.Component {
duration={this.props.noticeDuration}
width={width}
height={40}
onPress={(url) => {
this.props.onPressNotice && this.props.onPressNotice(url);
}}
onPress={this.props.onPressNotice}
/>
);
case 'list':
... ...
... ... @@ -68,21 +68,11 @@ export default class SectionList extends React.Component {
<ListCell
key={rowID}
data={rowData}
onPressPost={() => {
this.props.onPressPost && this.props.onPressPost(rowData.get('id'));
}}
onPressAvatar={() => {
this.props.onPressAvatar && this.props.onPressAvatar(rowData.get('author').get('uid'));
}}
onPressSectionTag={() => {
this.props.onPressSectionTag && this.props.onPressSectionTag(rowData.get('section').toJS());
}}
onPressComment={() => {
this.props.onPressComment && this.props.onPressComment(rowData.get('id'));
}}
onPressLike={() => {
this.props.onPressLike && this.props.onPressLike(rowData);
}}
onPressPost={this.props.onPressPost}
onPressAvatar={this.props.onPressAvatar}
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
/>
);
}
... ... @@ -102,9 +92,7 @@ export default class SectionList extends React.Component {
renderSeparator={this._renderSeparator}
enableEmptySections={true}
scrollEnabled={false}
onEndReached={() => {
}}
onEndReached={() => {}}
/>
);
... ...
... ... @@ -55,6 +55,7 @@ export default class User extends React.Component {
isOwner: React.PropTypes.bool,
isTop: React.PropTypes.bool,
isLike: React.PropTypes.bool,
id: React.PropTypes.number,
title: React.PropTypes.string,
desc: React.PropTypes.string,
thumbs: ImmutablePropTypes.listOf(
... ... @@ -81,6 +82,7 @@ export default class User extends React.Component {
isOwner: React.PropTypes.bool,
isTop: React.PropTypes.bool,
isLike: React.PropTypes.bool,
id: React.PropTypes.number,
title: React.PropTypes.string,
desc: React.PropTypes.string,
thumbs: ImmutablePropTypes.listOf(
... ...
... ... @@ -123,21 +123,11 @@ export default class UserThatNotMe extends React.Component {
<ListCell
key={sectionID + rowID}
data={rowData}
onPressPost={() => {
this.props.onPressPost && this.props.onPressPost(rowData.get('id'));
}}
onPressAvatar={() => {
this.props.onPressAvatar && this.props.onPressAvatar(rowData.get('author').get('uid'));
}}
onPressSectionTag={() => {
this.props.onPressSectionTag && this.props.onPressSectionTag(rowData.get('section').toJS());
}}
onPressComment={() => {
this.props.onPressComment && this.props.onPressComment(rowData.get('id'));
}}
onPressLike={() => {
this.props.onPressLike && this.props.onPressLike(rowData);
}}
onPressPost={this.props.onPressPost}
onPressAvatar={this.props.onPressAvatar}
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
/>
);
default:
... ...
... ... @@ -100,10 +100,10 @@ export function likeOperation(post) {
return (dispatch, getState) => {
let operation = () => {
if (post.get('isLike')) {
dispatch(postUnlike(post.get('id')));
if (post.isLike) {
dispatch(postUnlike(post.id));
} else {
dispatch(postLike(post.get('id')));
dispatch(postLike(post.id));
}
};
... ...