chore: evaluate `NewServerView` (#4101)

This commit is contained in:
Gerzon Z 2022-05-03 11:48:02 -04:00 committed by GitHub
parent 5dea514751
commit 99409d1af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -14,7 +14,7 @@ import Button from '../../containers/Button';
import FormContainer, { FormContainerInner } from '../../containers/FormContainer'; import FormContainer, { FormContainerInner } from '../../containers/FormContainer';
import * as HeaderButton from '../../containers/HeaderButton'; import * as HeaderButton from '../../containers/HeaderButton';
import OrSeparator from '../../containers/OrSeparator'; import OrSeparator from '../../containers/OrSeparator';
import { IBaseScreen, TServerHistoryModel } from '../../definitions'; import { IApplicationState, IBaseScreen, TServerHistoryModel } from '../../definitions';
import { withDimensions } from '../../dimensions'; import { withDimensions } from '../../dimensions';
import I18n from '../../i18n'; import I18n from '../../i18n';
import database from '../../lib/database'; import database from '../../lib/database';
@ -67,7 +67,7 @@ const styles = StyleSheet.create({
interface INewServerViewProps extends IBaseScreen<OutsideParamList, 'NewServerView'> { interface INewServerViewProps extends IBaseScreen<OutsideParamList, 'NewServerView'> {
connecting: boolean; connecting: boolean;
previousServer: string; previousServer: string | null;
width: number; width: number;
height: number; height: number;
} }
@ -75,7 +75,7 @@ interface INewServerViewProps extends IBaseScreen<OutsideParamList, 'NewServerVi
interface INewServerViewState { interface INewServerViewState {
text: string; text: string;
connectingOpen: boolean; connectingOpen: boolean;
certificate: any; certificate: string | null;
serversHistory: TServerHistoryModel[]; serversHistory: TServerHistoryModel[];
} }
@ -162,7 +162,9 @@ class NewServerView extends React.Component<INewServerViewProps, INewServerViewS
close = () => { close = () => {
const { dispatch, previousServer } = this.props; const { dispatch, previousServer } = this.props;
dispatch(inviteLinksClear()); dispatch(inviteLinksClear());
dispatch(selectServerRequest(previousServer)); if (previousServer) {
dispatch(selectServerRequest(previousServer));
}
}; };
handleNewServerEvent = (event: { server: string }) => { handleNewServerEvent = (event: { server: string }) => {
@ -265,8 +267,7 @@ class NewServerView extends React.Component<INewServerViewProps, INewServerViewS
showConfirmationAlert({ showConfirmationAlert({
message: I18n.t('You_will_unset_a_certificate_for_this_server'), message: I18n.t('You_will_unset_a_certificate_for_this_server'),
confirmationText: I18n.t('Remove'), confirmationText: I18n.t('Remove'),
// @ts-ignore onPress: () => this.setState({ certificate: null }) // We not need delete file from DocumentPicker because it is a temp file
onPress: this.setState({ certificate: null }) // We not need delete file from DocumentPicker because it is a temp file
}); });
}; };
@ -405,7 +406,7 @@ class NewServerView extends React.Component<INewServerViewProps, INewServerViewS
} }
} }
const mapStateToProps = (state: any) => ({ const mapStateToProps = (state: IApplicationState) => ({
connecting: state.server.connecting, connecting: state.server.connecting,
previousServer: state.server.previousServer previousServer: state.server.previousServer
}); });