Merge branch 'develop' into user-status

This commit is contained in:
Diego Mello 2017-12-05 11:13:25 -02:00 committed by GitHub
commit 261e7eb5cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 4 deletions

View File

@ -520,6 +520,12 @@ const RocketChat = {
emitTyping(room, t = true) {
const { login } = reduxStore.getState();
return call('stream-notify-room', `${ room }/typing`, login.user.username, t);
},
setUserPresenceAway() {
return call('UserPresence:away');
},
setUserPresenceOnline() {
return call('UserPresence:online');
}
};

View File

@ -1,8 +1,22 @@
import { takeLatest } from 'redux-saga/effects';
import { takeLatest, select } from 'redux-saga/effects';
import { FOREGROUND, BACKGROUND, INACTIVE } from 'redux-enhancer-react-native-appstate';
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() {
const auth = yield select(state => state.login.isAuthenticated);
if (!auth) {
return;
}
return yield RocketChat.setUserPresenceAway();
};
const root = function* root() {
@ -12,11 +26,11 @@ const root = function* root() {
);
yield takeLatest(
BACKGROUND,
appHasComeBackToForeground
appHasComeBackToBackground
);
yield takeLatest(
INACTIVE,
appHasComeBackToForeground
appHasComeBackToBackground
);
};