Fix add new server view

This commit is contained in:
Rodrigo Nascimento 2017-08-09 13:40:03 -03:00
parent 9f31e2606e
commit 6781b3052d
1 changed files with 3 additions and 12 deletions

View File

@ -2,8 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { TextInput, StyleSheet } from 'react-native'; import { TextInput, StyleSheet } from 'react-native';
import realm from '../lib/realm'; import RocketChat from '../lib/meteor';
import { connect } from '../lib/meteor';
import KeyboardView from '../components/KeyboardView'; import KeyboardView from '../components/KeyboardView';
@ -44,8 +43,6 @@ export default class NewServerView extends React.Component {
text: '' text: ''
}; };
const { navigate } = this.props.navigation;
this.submit = () => { this.submit = () => {
let url = this.state.text.trim(); let url = this.state.text.trim();
if (!url) { if (!url) {
@ -61,14 +58,8 @@ export default class NewServerView extends React.Component {
url = `https://${ url }`; url = `https://${ url }`;
} }
realm.write(() => { RocketChat.currentServer = url;
realm.objects('servers').filtered('current = true').forEach(item => (item.current = false)); this.props.navigation.dispatch({ type: 'Navigation/BACK' });
realm.create('servers', { id: url, current: true }, true);
});
connect(() => {
navigate('ListServer', { newServer: url });
});
}; };
} }