meteor connect saga

This commit is contained in:
Guilherme Gazzo 2017-08-16 22:09:44 -03:00
commit 4300b87035
No known key found for this signature in database
GPG Key ID: 1F85C9AD922D0829
7 changed files with 17 additions and 17 deletions

View File

@ -3,7 +3,7 @@ import * as types from './actionsTypes';
export function loginRequest(credentials) {
return {
type: types.LOGIN.REQUEST,
credentials
...credentials
};
}

View File

@ -154,7 +154,7 @@ const messagesSchema = {
// }
};
Realm.clearTestState();
// Realm.clearTestState();
const realm = new Realm({
schema: [settingsSchema, serversSchema, subscriptionSchema, messagesSchema, usersSchema, attachment]

View File

@ -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,12 +146,10 @@ const RocketChat = {
}
};
if (typeof username === 'string') {
if (username.indexOf('@') !== -1) {
if (typeof username === 'string' && username.indexOf('@') !== -1) {
params.user = { email: username };
}
}
}
if (code) {
params = {

View File

@ -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));

View File

@ -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));
}

View File

@ -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 (
<KeyboardView style={styles.view} keyboardVerticalOffset={64}>
{this.props.login.isFetching && <Text> INDO</Text>}
{this.props.login.isFetching && <Text> LOGANDO</Text>}
<TextInput
style={styles.input}
onChangeText={username => this.setState({ username })}

View File

@ -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);