diff --git a/app/actions/login.js b/app/actions/login.js index f593707f..cf9bd55e 100644 --- a/app/actions/login.js +++ b/app/actions/login.js @@ -3,7 +3,7 @@ import * as types from './actionsTypes'; export function loginRequest(credentials) { return { type: types.LOGIN.REQUEST, - credentials + ...credentials }; } diff --git a/app/lib/realm.js b/app/lib/realm.js index 5068a34b..b1219a3b 100644 --- a/app/lib/realm.js +++ b/app/lib/realm.js @@ -154,7 +154,7 @@ const messagesSchema = { // } }; -Realm.clearTestState(); +// Realm.clearTestState(); const realm = new Realm({ schema: [settingsSchema, serversSchema, subscriptionSchema, messagesSchema, usersSchema, attachment] diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 49556a49..11959ed3 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -106,10 +106,11 @@ const RocketChat = { }); }, - login(params, callback) { - return new Promise((resolve, reject) => { + async login(params, callback) { + await new Promise((resolve, reject) => { Meteor._startLoggingIn(); - Meteor.call('login', params, (err, result) => { + console.log('meteor login', params); + return Meteor.call('login', params, (err, result) => { Meteor._endLoggingIn(); Meteor._handleLoginCallback(err, result); err ? reject(err) : resolve(result); @@ -121,7 +122,6 @@ const RocketChat = { }, loginWithPassword({ username, password, code }, callback) { - console.log('AQQQQQ'); let params = {}; const state = reduxStore.getState(); @@ -146,10 +146,8 @@ const RocketChat = { } }; - if (typeof username === 'string') { - if (username.indexOf('@') !== -1) { - params.user = { email: username }; - } + if (typeof username === 'string' && username.indexOf('@') !== -1) { + params.user = { email: username }; } } diff --git a/app/sagas/connect.js b/app/sagas/connect.js index 1b8dff2e..deab72e0 100644 --- a/app/sagas/connect.js +++ b/app/sagas/connect.js @@ -11,6 +11,7 @@ function connect(...args) { const watchConnect = function* watchConnect() { while (true) { yield take(METEOR.REQUEST); + console.log('\n\n[METEOR CONNECTED]\n\n'); try { const response = yield call(connect); yield put(connectSuccess(response)); diff --git a/app/sagas/login.js b/app/sagas/login.js index dc12aedf..0f3c267e 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -4,17 +4,20 @@ import * as types from '../actions/actionsTypes'; import { loginSuccess, loginFailure } from '../actions/login'; import RocketChat from '../lib/rocketchat'; -function loginCall(...args) { - return RocketChat.loginWithPassword(...args); +function loginCall(args) { + console.log(args); + return RocketChat.loginWithPassword(args); } const watchLoginRequest = function* watchLoginRequest() { while (true) { yield take(types.METEOR.SUCCESS); + console.log('\n\n[LOGIN METEOR CONNECTED]\n\n'); const payload = yield take(types.LOGIN.REQUEST); try { const response = yield call(loginCall, payload); yield put(loginSuccess(response)); + console.log('\n\n[LOGIN SUCCESS]\n\n'); } catch (err) { yield put(loginFailure(err.status)); } diff --git a/app/views/login.js b/app/views/login.js index b65e0f35..3b6d0b39 100644 --- a/app/views/login.js +++ b/app/views/login.js @@ -66,7 +66,6 @@ class LoginView extends React.Component { submit = () => { const { username, password, code } = this.state; this.props.loginRequest({ username, password, code }); - console.log(this.props.loginRequest.toString()); // // // this.setState({ @@ -111,7 +110,7 @@ class LoginView extends React.Component { render() { return ( - {this.props.login.isFetching && INDO} + {this.props.login.isFetching && LOGANDO} this.setState({ username })} diff --git a/app/views/roomsList.js b/app/views/roomsList.js index d249b663..9b0831f3 100644 --- a/app/views/roomsList.js +++ b/app/views/roomsList.js @@ -229,11 +229,11 @@ export default class RoomsListView extends React.Component { } setInitialData = (props = this.props) => { + // console.log(this.props); + this.props.connect(); props.navigator.setSubTitle({ subtitle: props.server }); - - this.props.connect(); RocketChat.getUserToken().then((token) => { if (!token) { Navigation.showModal({ @@ -242,7 +242,6 @@ export default class RoomsListView extends React.Component { }); } - // this.props.actions.connect(); const data = realm.objects('subscriptions').filtered('_server.id = $0', props.server).sorted('_updatedAt', true);