Authored by 于良

Merge branch 'local' into develop

... ... @@ -176,6 +176,7 @@ export default function community(platform) {
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
onBack={this.onBack}
/>
<Scene
... ... @@ -199,6 +200,7 @@ export default function community(platform) {
return store.getState().posting.inPosting;
}
}
onBack={this.onBack}
/>
<Scene
... ... @@ -218,6 +220,7 @@ export default function community(platform) {
hideNavBar={false}
component={MessageCenterContainer}
initial={false}
onBack={this.onBack}
/>
<Scene
... ... @@ -226,6 +229,7 @@ export default function community(platform) {
hideNavBar={false}
component={LikeMessageContainer}
initial={false}
onBack={this.onBack}
/>
<Scene
... ... @@ -237,6 +241,7 @@ export default function community(platform) {
rightTitle='确认'
onRight={this.settingOnRight}
rightButtonTextStyle={{color: 'white'}}
onBack={this.onBack}
/>
<Scene
... ... @@ -258,6 +263,7 @@ export default function community(platform) {
hideNavBar={false}
component={SubjectPostContainer}
initial={false}
onBack={this.onBack}
/>
<Scene
... ... @@ -286,10 +292,10 @@ export default function community(platform) {
}
}}
rightButtonTextStyle={[styles.barRightButtonText,{color:store.getState().posting.dataValid?'white':'#a0a0a0'}]}
onBack={()=>{
onBack={(navigationState) => {
let dismissKeyboard = require('dismissKeyboard');
dismissKeyboard();
Actions.pop();
this.onBack(navigationState);
}}
/>
... ... @@ -302,8 +308,6 @@ export default function community(platform) {
renderHomeTitle(navProps) {
let {width, height} = Dimensions.get('window');
return (
<Animated.View style={[styles.title,]}>
<TouchableOpacity onPress={() => {
... ... @@ -345,7 +349,6 @@ export default function community(platform) {
/>
</TouchableOpacity>
<View style={{
backgroundColor: 'white',
position: 'absolute',
... ... @@ -358,6 +361,15 @@ export default function community(platform) {
);
},
onBack(navigationState) {
Actions.pop();
let children = navigationState.children;
let home = children[0];
if (children.length == 2 && home.sceneKey == 'Home') {
ReactNative.NativeModules.YH_CommunityHelper.showTabBar();
}
},
homeOnRight(state) {
state.dispatch(startEditPost(state.getPostingState()));
},
... ...
... ... @@ -223,7 +223,7 @@ class NavBar extends React.Component {
}
let buttonImage = childState.backButtonImage ||
state.backButtonImage || this.props.backButtonImage;
let onPress = childState.onBack || Actions.pop;
let onPress = (childState.onBack && childState.onBack.bind(null, state)) || Actions.pop;
if (state.index === 0) {
return null;
... ...
... ... @@ -378,7 +378,8 @@ export default class User extends React.Component {
hasRightButton={true}
msgCount={this.props.profile.msgCount}
rightButtonClick={this.props.rightButtonClick}
/>
onBack={this.props.onBack}
/>
</View>
);
... ...
... ... @@ -141,7 +141,7 @@ class UserNavBar extends React.Component {
}
renderBackButton() {
let onPress = Actions.pop;
let onPress = this.props.onBack || Actions.pop;
return (
<TouchableOpacity
style={styles.backButton}
... ...
... ... @@ -180,7 +180,11 @@ export default class UserThatNotMe extends React.Component {
}}
/>
<UserNavBar scrollValue={this.state.scrollValue} channel={this.props.channel}/>
<UserNavBar
scrollValue={this.state.scrollValue}
channel={this.props.channel}
onBack={this.props.onBack}
/>
</View>
)
... ...
... ... @@ -124,13 +124,6 @@ class HomeContainer extends React.Component {
});
}
componentWillReceiveProps(nextProps) {
if (nextProps.showNativeTabBar) {
ReactNative.NativeModules.YH_CommunityHelper.showTabBar();
Actions.refresh({key: 'Home', showNativeTabBar: false});
}
}
componentWillUnmount() {
if (parseInt(this.props.app.container) === 1) {
this.subscription && this.subscription.remove();
... ...
... ... @@ -63,9 +63,7 @@ class LikeMessageContainer extends React.Component {
}
componentWillUnmount() {
if (shouldShowTabBar(this.props.navigationState)) {
Actions.refresh({key: 'Home', showNativeTabBar: true});
}
}
_onPressPost(id) {
... ...
... ... @@ -84,9 +84,7 @@ class PostingContainer extends Component{
}
componentWillUnmount() {
if (shouldShowTabBar(this.props.navigationState)) {
Actions.refresh({key: 'Home', showNativeTabBar: true});
}
}
componentWillReceiveProps(nextProps) {
... ...
... ... @@ -92,10 +92,6 @@ class SectionContainer extends React.Component {
}
componentWillUnmount() {
if (shouldShowTabBar(this.props.navigationState)) {
Actions.refresh({key: 'Home', showNativeTabBar: true});
}
this.props.actions.sectionClean(this.sid);
}
... ...
... ... @@ -78,6 +78,7 @@ class UserContainer extends React.Component {
this._onEndReached = this._onEndReached.bind(this);
this._rightButtonClick = this._rightButtonClick.bind(this);
this._onPressSectionTag = this._onPressSectionTag.bind(this);
this._onBack = this._onBack.bind(this);
}
componentDidMount() {
... ... @@ -100,14 +101,16 @@ class UserContainer extends React.Component {
}
componentWillUnmount() {
if (shouldShowTabBar(this.props.navigationState)) {
Actions.refresh({key: 'Home', showNativeTabBar: true});
}
this.props.actions.userClean();
this.observer.remove();
this.observer && this.observer.remove();
}
_onBack() {
Actions.pop();
if (shouldShowTabBar(this.props.navigationState)) {
ReactNative.NativeModules.YH_CommunityHelper.showTabBar();
}
}
// private method
_onPressAvatar(url) {
... ... @@ -204,8 +207,6 @@ class UserContainer extends React.Component {
});
}
_onRefresh() {
InteractionManager.runAfterInteractions(() => {
this.props.actions.posts(true);
... ... @@ -235,8 +236,9 @@ class UserContainer extends React.Component {
console.log('message clicked-----------');
this.props.actions.goToMessageCenter();
}
render() {
render() {
console.log(this.props);
let {profile, activeTab, isFetching, ptr, posts: postsData, like: likeData, reply: replyData} = this.props.user;
let listData = Immutable.fromJS([{posts: postsData.list, like: likeData.list, reply: replyData.list}]);
let isRefreshing = ptr;
... ... @@ -284,6 +286,7 @@ class UserContainer extends React.Component {
isLoadingMore={isLoadingMore}
onEndReached={this._onEndReached}
rightButtonClick={this._rightButtonClick}
onBack={this._onBack}
/>
</View>
);
... ...
... ... @@ -57,6 +57,7 @@ class UserThatNotMeContainer extends React.Component {
this._onPressComment = this._onPressComment.bind(this);
this._onPressLike = this._onPressLike.bind(this);
this._onEndReached = this._onEndReached.bind(this);
this._onBack = this._onBack.bind(this);
this.sid = this.props.userThatNotMe.sid;
}
... ... @@ -72,11 +73,14 @@ class UserThatNotMeContainer extends React.Component {
}
componentWillUnmount() {
this.props.actions.userThatNotMeClean(this.sid);
}
_onBack() {
Actions.pop();
if (shouldShowTabBar(this.props.navigationState)) {
Actions.refresh({key: 'Home', showNativeTabBar: true});
ReactNative.NativeModules.YH_CommunityHelper.showTabBar();
}
this.props.actions.userThatNotMeClean();
}
_onPressAvatar(uid) {
... ... @@ -124,6 +128,7 @@ class UserThatNotMeContainer extends React.Component {
onPressComment={this._onPressComment}
onPressLike={this._onPressLike}
onPressPost={this._onPressPost}
onBack={this._onBack}
/>
</View>
);
... ...
... ... @@ -95,6 +95,9 @@ export function header(sid) {
let {section} = getState();
let item = section.items.get(sid);
if (!item) {
return;
}
if (item.isFetching) {
return;
... ... @@ -133,6 +136,9 @@ export function newPost(sid, ptr = false) {
return (dispatch, getState) => {
let {section, user} = getState();
let item = section.items.get(sid);
if (!item) {
return;
}
// 接口请求跳出的条件:
// 前置条件:下拉刷新优先级高于上拉加载
... ... @@ -175,6 +181,10 @@ export function hotPost(sid, ptr = false) {
return (dispatch, getState) => {
let {section, user} = getState();
let item = section.items.get(sid);
if (!item) {
return;
}
// 接口请求跳出的条件:
// 前置条件:下拉刷新优先级高于上拉加载
if (ptr) {
... ...
... ... @@ -152,9 +152,11 @@ export default function sectionReducer(state = initialState, action) {
case SECTION_SET_ACTIVE_TAB: {
let {sid, tab} = action.payload;
let item = state.items.get(sid);
item = item.set('activeTab', tab);
let nextState = state.setIn(['items', sid], item);
return nextState;
if (item) {
item = item.set('activeTab', tab);
let nextState = state.setIn(['items', sid], item);
return nextState;
}
}
case POST_LIKE_REQUEST: {
... ...
... ... @@ -60,6 +60,10 @@ export function getUserThatNotMeInfo(sid) {
return (dispatch, getState) => {
let {userThatNotMe} = getState();
let item = userThatNotMe.items.get(sid);
if (!item) {
return;
}
if (item.profile.isFetching || item.profile.error) {
return;
}
... ... @@ -103,6 +107,10 @@ export function userThatNotMePosts(sid) {
return (dispatch, getState) => {
let {user, userThatNotMe} = getState();
let item = userThatNotMe.items.get(sid);
if (!item) {
return;
}
if (item.posts.isFetching || item.posts.error) {
return;
}
... ...