[FIX] NewServerView skipping WorkspaceView (#3455)

* Initial commit

* Fix interface

* Unrequired change on onPress/onSubmit
This commit is contained in:
Gerzon Z 2021-10-26 09:39:13 -04:00 committed by GitHub
parent 0a44731229
commit 87a99089ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { FlatList, StyleSheet, View } from 'react-native';
import { FlatList, StyleSheet, TextInputProps, View } from 'react-native';
import TextInput from '../../../containers/TextInput';
import * as List from '../../../containers/List';
@ -28,11 +28,10 @@ const styles = StyleSheet.create({
}
});
interface IServerInput {
interface IServerInput extends TextInputProps {
text: string;
theme: string;
serversHistory: any[];
onChangeText(text: string): void;
onSubmit(): void;
onDelete(item: IServer): void;
onPressServerHistory(serverHistory: IServer): void;

View File

@ -71,6 +71,7 @@ export interface IServer extends Model {
url: string;
username: string;
}
interface INewServerView {
navigation: StackNavigationProp<any, 'NewServerView'>;
theme: string;
@ -91,6 +92,11 @@ interface IState {
serversHistory: IServer[];
}
interface ISubmitParams {
fromServerHistory?: boolean;
username?: string;
}
class NewServerView extends React.Component<INewServerView, IState> {
constructor(props: INewServerView) {
super(props);
@ -184,10 +190,10 @@ class NewServerView extends React.Component<INewServerView, IState> {
};
onPressServerHistory = (serverHistory: IServer) => {
this.setState({ text: serverHistory.url }, () => this.submit(true, serverHistory?.username));
this.setState({ text: serverHistory.url }, () => this.submit({ fromServerHistory: true, username: serverHistory?.username }));
};
submit = async (fromServerHistory?: boolean, username?: string) => {
submit = async ({ fromServerHistory = false, username }: ISubmitParams = {}) => {
logEvent(events.NS_CONNECT_TO_WORKSPACE);
const { text, certificate } = this.state;
const { connectServer } = this.props;