[FIX] Cant add new server

This commit is contained in:
Rodrigo Nascimento 2017-08-13 22:13:48 -03:00
parent b719814ffe
commit e8c77361c3
1 changed files with 6 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { Navigation } from 'react-native-navigation'; import { Navigation } from 'react-native-navigation';
import { Text, TextInput, View, StyleSheet } from 'react-native'; import { Text, TextInput, View, StyleSheet } from 'react-native';
import _ from 'underscore'; import _ from 'underscore';
import realm from '../lib/realm';
import KeyboardView from '../components/KeyboardView'; import KeyboardView from '../components/KeyboardView';
@ -47,7 +48,6 @@ const styles = StyleSheet.create({
} }
}); });
export default class NewServerView extends React.Component { export default class NewServerView extends React.Component {
static propTypes = { static propTypes = {
navigator: PropTypes.object.isRequired navigator: PropTypes.object.isRequired
@ -79,6 +79,9 @@ export default class NewServerView extends React.Component {
this.inputElement.blur(); this.inputElement.blur();
this.validateServer(url).then(() => { this.validateServer(url).then(() => {
realm.write(() => {
realm.create('servers', { id: url, current: false }, true);
});
Navigation.dismissModal({ Navigation.dismissModal({
animationType: 'slide-down' animationType: 'slide-down'
}); });
@ -142,7 +145,7 @@ export default class NewServerView extends React.Component {
validating: true validating: true
}); });
const a = fetch(url, { method: 'HEAD' }) fetch(url, { method: 'HEAD' })
.then((response) => { .then((response) => {
if (!this._mounted) { if (!this._mounted) {
return; return;
@ -171,7 +174,7 @@ export default class NewServerView extends React.Component {
}); });
reject(url); reject(url);
}); });
console.log(a.stop);
} else { } else {
this.setState({ this.setState({
validInstance: undefined validInstance: undefined