- User presence away when app goes to background
- User presence online when app comes back to foreground
This commit is contained in:
parent
caf0f2354c
commit
e1a0134021
|
@ -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');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
import { takeLatest } 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');
|
||||
return yield RocketChat.setUserPresenceOnline();
|
||||
};
|
||||
|
||||
const appHasComeBackToBackground = function* appHasComeBackToBackground() {
|
||||
yield console.log('appHasComeBackToBackground');
|
||||
return yield RocketChat.setUserPresenceAway();
|
||||
};
|
||||
|
||||
const root = function* root() {
|
||||
|
@ -12,11 +19,11 @@ const root = function* root() {
|
|||
);
|
||||
yield takeLatest(
|
||||
BACKGROUND,
|
||||
appHasComeBackToForeground
|
||||
appHasComeBackToBackground
|
||||
);
|
||||
yield takeLatest(
|
||||
INACTIVE,
|
||||
appHasComeBackToForeground
|
||||
appHasComeBackToBackground
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue