meteor connect saga
This commit is contained in:
commit
4300b87035
|
@ -3,7 +3,7 @@ import * as types from './actionsTypes';
|
|||
export function loginRequest(credentials) {
|
||||
return {
|
||||
type: types.LOGIN.REQUEST,
|
||||
credentials
|
||||
...credentials
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ const messagesSchema = {
|
|||
// }
|
||||
};
|
||||
|
||||
Realm.clearTestState();
|
||||
// Realm.clearTestState();
|
||||
|
||||
const realm = new Realm({
|
||||
schema: [settingsSchema, serversSchema, subscriptionSchema, messagesSchema, usersSchema, attachment]
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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 })}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue