* [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 Navigation from '../lib/Navigation';
|
||||||
import * as types from '../actions/actionsTypes';
|
import * as types from '../actions/actionsTypes';
|
||||||
import { selectServerRequest } from '../actions/server';
|
import { selectServerRequest, serverInitAdd } from '../actions/server';
|
||||||
import { inviteLinksSetToken, inviteLinksRequest } from '../actions/inviteLinks';
|
import { inviteLinksSetToken, inviteLinksRequest } from '../actions/inviteLinks';
|
||||||
import database from '../lib/database';
|
import database from '../lib/database';
|
||||||
import RocketChat from '../lib/rocketchat';
|
import RocketChat from '../lib/rocketchat';
|
||||||
import EventEmitter from '../utils/events';
|
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 { localAuthenticate } from '../utils/localAuthentication';
|
||||||
import { goRoom } from '../utils/goRoom';
|
import { goRoom } from '../utils/goRoom';
|
||||||
|
|
||||||
|
@ -106,7 +106,8 @@ const handleOpen = function* handleOpen({ params }) {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Navigation.navigate('NewServerView', { previousServer: server });
|
yield put(appStart({ root: ROOT_NEW_SERVER }));
|
||||||
|
yield put(serverInitAdd(server));
|
||||||
yield delay(1000);
|
yield delay(1000);
|
||||||
EventEmitter.emit('NewServer', { server: host });
|
EventEmitter.emit('NewServer', { server: host });
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import parse from 'url-parse';
|
||||||
|
|
||||||
import EventEmitter from '../utils/events';
|
import EventEmitter from '../utils/events';
|
||||||
import { selectServerRequest, serverRequest } from '../actions/server';
|
import { selectServerRequest, serverRequest } from '../actions/server';
|
||||||
|
import { inviteLinksClear as inviteLinksClearAction } from '../actions/inviteLinks';
|
||||||
import sharedStyles from './Styles';
|
import sharedStyles from './Styles';
|
||||||
import Button from '../containers/Button';
|
import Button from '../containers/Button';
|
||||||
import TextInput from '../containers/TextInput';
|
import TextInput from '../containers/TextInput';
|
||||||
|
@ -72,16 +73,13 @@ class NewServerView extends React.Component {
|
||||||
connectServer: PropTypes.func.isRequired,
|
connectServer: PropTypes.func.isRequired,
|
||||||
selectServer: PropTypes.func.isRequired,
|
selectServer: PropTypes.func.isRequired,
|
||||||
adding: PropTypes.bool,
|
adding: PropTypes.bool,
|
||||||
previousServer: PropTypes.string
|
previousServer: PropTypes.string,
|
||||||
|
inviteLinksClear: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
if (props.adding) {
|
this.setHeader();
|
||||||
props.navigation.setOptions({
|
|
||||||
headerLeft: () => <CloseModalButton navigation={props.navigation} onPress={this.close} testID='new-server-view-close' />
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
text: '',
|
text: '',
|
||||||
|
@ -92,11 +90,27 @@ class NewServerView extends React.Component {
|
||||||
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
|
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
const { adding } = this.props;
|
||||||
|
if (prevProps.adding !== adding) {
|
||||||
|
this.setHeader();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
EventEmitter.removeListener('NewServer', this.handleNewServerEvent);
|
EventEmitter.removeListener('NewServer', this.handleNewServerEvent);
|
||||||
BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
|
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 = () => {
|
handleBackPress = () => {
|
||||||
const { navigation, previousServer } = this.props;
|
const { navigation, previousServer } = this.props;
|
||||||
if (navigation.isFocused() && previousServer) {
|
if (navigation.isFocused() && previousServer) {
|
||||||
|
@ -111,7 +125,8 @@ class NewServerView extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
close = () => {
|
close = () => {
|
||||||
const { selectServer, previousServer } = this.props;
|
const { selectServer, previousServer, inviteLinksClear } = this.props;
|
||||||
|
inviteLinksClear();
|
||||||
selectServer(previousServer);
|
selectServer(previousServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +339,8 @@ const mapStateToProps = state => ({
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
connectServer: (server, certificate) => dispatch(serverRequest(server, certificate)),
|
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));
|
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewServerView));
|
||||||
|
|
Loading…
Reference in New Issue