From 87a99089cee007c3ed91e48d49cb6fe2aedd4b67 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Tue, 26 Oct 2021 09:39:13 -0400 Subject: [PATCH] [FIX] NewServerView skipping WorkspaceView (#3455) * Initial commit * Fix interface * Unrequired change on onPress/onSubmit --- app/views/NewServerView/ServerInput/index.tsx | 5 ++--- app/views/NewServerView/index.tsx | 10 ++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/views/NewServerView/ServerInput/index.tsx b/app/views/NewServerView/ServerInput/index.tsx index c3399b730..1da151367 100644 --- a/app/views/NewServerView/ServerInput/index.tsx +++ b/app/views/NewServerView/ServerInput/index.tsx @@ -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; diff --git a/app/views/NewServerView/index.tsx b/app/views/NewServerView/index.tsx index 815ec1347..f1458c93a 100644 --- a/app/views/NewServerView/index.tsx +++ b/app/views/NewServerView/index.tsx @@ -71,6 +71,7 @@ export interface IServer extends Model { url: string; username: string; } + interface INewServerView { navigation: StackNavigationProp; theme: string; @@ -91,6 +92,11 @@ interface IState { serversHistory: IServer[]; } +interface ISubmitParams { + fromServerHistory?: boolean; + username?: string; +} + class NewServerView extends React.Component { constructor(props: INewServerView) { super(props); @@ -184,10 +190,10 @@ class NewServerView extends React.Component { }; 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;