cancel add server
This commit is contained in:
parent
9ed35f0f1d
commit
fa87dc6c58
|
@ -5,7 +5,7 @@ import { connect } from 'react-redux';
|
|||
|
||||
import Navigation from './lib/Navigation';
|
||||
import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/navigation';
|
||||
import { ROOT_INSIDE, ROOT_LOADING, ROOT_OUTSIDE, ROOT_SET_USERNAME } from './actions/app';
|
||||
import { ROOT_INSIDE, ROOT_LOADING, ROOT_NEW_SERVER, ROOT_OUTSIDE, ROOT_SET_USERNAME } from './actions/app';
|
||||
// Stacks
|
||||
import AuthLoadingView from './views/AuthLoadingView';
|
||||
// SetUsername Stack
|
||||
|
@ -56,7 +56,9 @@ const App = React.memo(({ root, isMasterDetail }: { root: string; isMasterDetail
|
|||
<Stack.Navigator screenOptions={{ headerShown: false, animationEnabled: false }}>
|
||||
<>
|
||||
{root === ROOT_LOADING ? <Stack.Screen name='AuthLoading' component={AuthLoadingView} /> : null}
|
||||
{root === ROOT_OUTSIDE ? <Stack.Screen name='OutsideStack' component={OutsideStack} /> : null}
|
||||
{root === ROOT_OUTSIDE || root === ROOT_NEW_SERVER ? (
|
||||
<Stack.Screen name='OutsideStack' component={OutsideStack} />
|
||||
) : null}
|
||||
{root === ROOT_INSIDE && isMasterDetail ? (
|
||||
<Stack.Screen name='MasterDetailStack' component={MasterDetailStack} />
|
||||
) : null}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { APP } from './actionsTypes';
|
||||
|
||||
export const ROOT_OUTSIDE = 'outside';
|
||||
export const ROOT_NEW_SERVER = 'newServer';
|
||||
export const ROOT_INSIDE = 'inside';
|
||||
export const ROOT_LOADING = 'loading';
|
||||
export const ROOT_SET_USERNAME = 'setUsername';
|
||||
|
|
|
@ -9,6 +9,7 @@ import { TouchableOpacity } from 'react-native-gesture-handler';
|
|||
|
||||
import UserPreferences from '../../lib/userPreferences';
|
||||
import EventEmitter from '../../utils/events';
|
||||
import { ROOT_NEW_SERVER } from '../../actions/app';
|
||||
import { selectServerRequest, serverRequest } from '../../actions/server';
|
||||
import { inviteLinksClear as inviteLinksClearAction } from '../../actions/inviteLinks';
|
||||
import sharedStyles from '../Styles';
|
||||
|
@ -77,10 +78,6 @@ const styles = StyleSheet.create({
|
|||
});
|
||||
|
||||
class NewServerView extends React.Component {
|
||||
static navigationOptions = {
|
||||
headerShown: false
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
navigation: PropTypes.object,
|
||||
theme: PropTypes.string,
|
||||
|
@ -89,7 +86,8 @@ class NewServerView extends React.Component {
|
|||
selectServer: PropTypes.func.isRequired,
|
||||
adding: PropTypes.bool,
|
||||
previousServer: PropTypes.string,
|
||||
inviteLinksClear: PropTypes.func
|
||||
inviteLinksClear: PropTypes.func,
|
||||
root: PropTypes.string
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
|
@ -123,11 +121,16 @@ class NewServerView extends React.Component {
|
|||
}
|
||||
|
||||
setHeader = () => {
|
||||
const { adding, navigation } = this.props;
|
||||
if (adding) {
|
||||
const { adding, navigation, root } = this.props;
|
||||
if (adding && root === ROOT_NEW_SERVER) {
|
||||
navigation.setOptions({
|
||||
headerTitle: I18n.t('Workspaces'),
|
||||
headerLeft: () => <HeaderButton.CloseModal navigation={navigation} onPress={this.close} testID='new-server-view-close' />
|
||||
});
|
||||
} else {
|
||||
navigation.setOptions({
|
||||
headerShown: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -365,7 +368,8 @@ class NewServerView extends React.Component {
|
|||
const mapStateToProps = state => ({
|
||||
connecting: state.server.connecting,
|
||||
adding: state.server.adding,
|
||||
previousServer: state.server.previousServer
|
||||
previousServer: state.server.previousServer,
|
||||
root: state.app.root
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as List from '../../containers/List';
|
|||
import Button from '../../containers/Button';
|
||||
import { toggleServerDropdown as toggleServerDropdownAction } from '../../actions/rooms';
|
||||
import { selectServerRequest as selectServerRequestAction, serverInitAdd as serverInitAddAction } from '../../actions/server';
|
||||
import { ROOT_OUTSIDE, appStart as appStartAction } from '../../actions/app';
|
||||
import { appStart as appStartAction, ROOT_NEW_SERVER } from '../../actions/app';
|
||||
import RocketChat from '../../lib/rocketchat';
|
||||
import I18n from '../../i18n';
|
||||
import EventEmitter from '../../utils/events';
|
||||
|
@ -111,7 +111,7 @@ class ServerDropdown extends Component {
|
|||
navToNewServer = previousServer => {
|
||||
const { appStart, initAdd } = this.props;
|
||||
batch(() => {
|
||||
appStart({ root: ROOT_OUTSIDE });
|
||||
appStart({ root: ROOT_NEW_SERVER });
|
||||
initAdd(previousServer);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue