* [REGRESSION] Invite links stopped working after #2154 * Clear invite links token when close NewServerView Co-authored-by: Djorkaeff Alexandre <djorkaeff.unb@gmail.com>
This commit is contained in:
parent
c91cd0b963
commit
09a8be8b59
|
@ -5,12 +5,12 @@ import RNUserDefaults from 'rn-user-defaults';
|
|||
|
||||
import Navigation from '../lib/Navigation';
|
||||
import * as types from '../actions/actionsTypes';
|
||||
import { selectServerRequest } from '../actions/server';
|
||||
import { selectServerRequest, serverInitAdd } from '../actions/server';
|
||||
import { inviteLinksSetToken, inviteLinksRequest } from '../actions/inviteLinks';
|
||||
import database from '../lib/database';
|
||||
import RocketChat from '../lib/rocketchat';
|
||||
import EventEmitter from '../utils/events';
|
||||
import { appStart, ROOT_INSIDE } from '../actions/app';
|
||||
import { appStart, ROOT_INSIDE, ROOT_NEW_SERVER } from '../actions/app';
|
||||
import { localAuthenticate } from '../utils/localAuthentication';
|
||||
import { goRoom } from '../utils/goRoom';
|
||||
|
||||
|
@ -106,7 +106,8 @@ const handleOpen = function* handleOpen({ params }) {
|
|||
if (!result.success) {
|
||||
return;
|
||||
}
|
||||
Navigation.navigate('NewServerView', { previousServer: server });
|
||||
yield put(appStart({ root: ROOT_NEW_SERVER }));
|
||||
yield put(serverInitAdd(server));
|
||||
yield delay(1000);
|
||||
EventEmitter.emit('NewServer', { server: host });
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import parse from 'url-parse';
|
|||
|
||||
import EventEmitter from '../utils/events';
|
||||
import { selectServerRequest, serverRequest } from '../actions/server';
|
||||
import { inviteLinksClear as inviteLinksClearAction } from '../actions/inviteLinks';
|
||||
import sharedStyles from './Styles';
|
||||
import Button from '../containers/Button';
|
||||
import TextInput from '../containers/TextInput';
|
||||
|
@ -72,16 +73,13 @@ class NewServerView extends React.Component {
|
|||
connectServer: PropTypes.func.isRequired,
|
||||
selectServer: PropTypes.func.isRequired,
|
||||
adding: PropTypes.bool,
|
||||
previousServer: PropTypes.string
|
||||
previousServer: PropTypes.string,
|
||||
inviteLinksClear: PropTypes.func
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
if (props.adding) {
|
||||
props.navigation.setOptions({
|
||||
headerLeft: () => <CloseModalButton navigation={props.navigation} onPress={this.close} testID='new-server-view-close' />
|
||||
});
|
||||
}
|
||||
this.setHeader();
|
||||
|
||||
this.state = {
|
||||
text: '',
|
||||
|
@ -92,11 +90,27 @@ class NewServerView extends React.Component {
|
|||
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { adding } = this.props;
|
||||
if (prevProps.adding !== adding) {
|
||||
this.setHeader();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
EventEmitter.removeListener('NewServer', this.handleNewServerEvent);
|
||||
BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
|
||||
}
|
||||
|
||||
setHeader = () => {
|
||||
const { adding, navigation } = this.props;
|
||||
if (adding) {
|
||||
navigation.setOptions({
|
||||
headerLeft: () => <CloseModalButton navigation={navigation} onPress={this.close} testID='new-server-view-close' />
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleBackPress = () => {
|
||||
const { navigation, previousServer } = this.props;
|
||||
if (navigation.isFocused() && previousServer) {
|
||||
|
@ -111,7 +125,8 @@ class NewServerView extends React.Component {
|
|||
}
|
||||
|
||||
close = () => {
|
||||
const { selectServer, previousServer } = this.props;
|
||||
const { selectServer, previousServer, inviteLinksClear } = this.props;
|
||||
inviteLinksClear();
|
||||
selectServer(previousServer);
|
||||
}
|
||||
|
||||
|
@ -324,7 +339,8 @@ const mapStateToProps = state => ({
|
|||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
connectServer: (server, certificate) => dispatch(serverRequest(server, certificate)),
|
||||
selectServer: server => dispatch(selectServerRequest(server))
|
||||
selectServer: server => dispatch(selectServerRequest(server)),
|
||||
inviteLinksClear: () => dispatch(inviteLinksClearAction())
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewServerView));
|
||||
|
|
Loading…
Reference in New Issue