PLT-5502 Update statuses (#302)
This commit is contained in:
parent
c1318fe834
commit
e6547c6970
4 changed files with 33 additions and 2 deletions
|
|
@ -14,7 +14,9 @@ export default class Root extends React.Component {
|
|||
locale: React.PropTypes.string.isRequired,
|
||||
actions: React.PropTypes.shape({
|
||||
loadConfigAndLicense: React.PropTypes.func.isRequired,
|
||||
setAppState: React.PropTypes.func
|
||||
startPeriodicStatusUpdates: React.PropTypes.func.isRequired,
|
||||
stopPeriodicStatusUpdates: React.PropTypes.func.isRequired,
|
||||
setAppState: React.PropTypes.func.isRequired
|
||||
}).isRequired
|
||||
};
|
||||
|
||||
|
|
@ -29,11 +31,13 @@ export default class Root extends React.Component {
|
|||
componentDidMount() {
|
||||
AppState.addEventListener('change', this.handleAppStateChange);
|
||||
EventEmitter.on(Constants.CONFIG_CHANGED, this.handleConfigChanged);
|
||||
this.props.actions.startPeriodicStatusUpdates();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
AppState.removeEventListener('change', this.handleAppStateChange);
|
||||
EventEmitter.off(Constants.CONFIG_CHANGED, this.handleConfigChanged);
|
||||
this.props.actions.stopPeriodicStatusUpdates();
|
||||
}
|
||||
|
||||
handleAppStateChange(appState) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import Config from 'assets/config.json';
|
|||
|
||||
import {loadConfigAndLicense} from 'app/actions/views/root';
|
||||
import {setAppState} from 'service/actions/general';
|
||||
import {startPeriodicStatusUpdates, stopPeriodicStatusUpdates} from 'service/actions/users';
|
||||
|
||||
import Root from './root';
|
||||
|
||||
|
|
@ -30,6 +31,8 @@ function mapDispatchToProps(dispatch) {
|
|||
return {
|
||||
actions: bindActionCreators({
|
||||
loadConfigAndLicense,
|
||||
startPeriodicStatusUpdates,
|
||||
stopPeriodicStatusUpdates,
|
||||
setAppState
|
||||
}, dispatch)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -369,6 +369,27 @@ export function searchProfiles(term, options) {
|
|||
);
|
||||
}
|
||||
|
||||
let statusIntervalId = '';
|
||||
export function startPeriodicStatusUpdates() {
|
||||
return async (dispatch, getState) => {
|
||||
clearInterval(statusIntervalId);
|
||||
|
||||
statusIntervalId = setInterval(
|
||||
() => {
|
||||
const {statuses} = getState().entities.users;
|
||||
getStatusesByIds(Object.keys(statuses))(dispatch, getState);
|
||||
},
|
||||
Constants.STATUS_INTERVAL
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export function stopPeriodicStatusUpdates() {
|
||||
return async () => {
|
||||
clearInterval(statusIntervalId);
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
checkMfa,
|
||||
login,
|
||||
|
|
@ -382,5 +403,7 @@ export default {
|
|||
getSessions,
|
||||
revokeSession,
|
||||
getAudits,
|
||||
searchProfiles
|
||||
searchProfiles,
|
||||
startPeriodicStatusUpdates,
|
||||
stopPeriodicStatusUpdates
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ const Constants = {
|
|||
PROFILE_CHUNK_SIZE: 100,
|
||||
CHANNELS_CHUNK_SIZE: 50,
|
||||
SEARCH_TIMEOUT_MILLISECONDS: 100,
|
||||
STATUS_INTERVAL: 60000,
|
||||
|
||||
MENTION: 'mention',
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue