test if user is connected before call userpresence

This commit is contained in:
Guilherme Gazzo 2017-12-04 15:36:01 -02:00
parent 6096ade896
commit 59cf83f2d3
No known key found for this signature in database
GPG Key ID: 1F85C9AD922D0829
1 changed files with 10 additions and 3 deletions

View File

@ -1,14 +1,21 @@
import { takeLatest } from 'redux-saga/effects';
import { takeLatest, take, select } from 'redux-saga/effects';
import { FOREGROUND, BACKGROUND, INACTIVE } from 'redux-enhancer-react-native-appstate';
import { LOGIN } from '../actions/actionsTypes';
import RocketChat from '../lib/rocketchat';
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
yield console.log('appHasComeBackToForeground');
const auth = yield select(state => state.login.isAuthenticated);
if (!auth) {
return;
}
return yield RocketChat.setUserPresenceOnline();
};
const appHasComeBackToBackground = function* appHasComeBackToBackground() {
yield console.log('appHasComeBackToBackground');
const auth = yield select(state => state.login.isAuthenticated);
if (!auth) {
return;
}
return yield RocketChat.setUserPresenceAway();
};