PLT-2241 Refactored statuses into a more real-time system (#3573)
* Refactored statuses into a more real-time system * Updated package.json with correct commit and fixed minor bug * Minor updates to statuses based on feedback * When setting status online, update only LastActivityAt if status already exists
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
180adc79af
Коммит
c0ab2636d6
@@ -29,6 +29,7 @@ import * as TextFormatting from 'utils/text_formatting.jsx';
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
import Client from 'utils/web_client.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
const UserStatuses = Constants.UserStatuses;
|
||||
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
import {browserHistory} from 'react-router/es6';
|
||||
@@ -189,6 +190,7 @@ export default class ChannelHeader extends React.Component {
|
||||
if (teammate) {
|
||||
return UserStore.getStatus(teammate.id);
|
||||
}
|
||||
return UserStatuses.OFFLINE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,12 @@ import UserStore from 'stores/user_store.jsx';
|
||||
import BrowserStore from 'stores/browser_store.jsx';
|
||||
import PreferenceStore from 'stores/preference_store.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import * as Websockets from 'actions/websocket_actions.jsx';
|
||||
import * as GlobalActions from 'actions/global_actions.jsx';
|
||||
import * as WebSocketActions from 'actions/websocket_actions.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
|
||||
import {browserHistory} from 'react-router/es6';
|
||||
|
||||
const CLIENT_STATUS_INTERVAL = 30000;
|
||||
const BACKSPACE_CHAR = 8;
|
||||
|
||||
import React from 'react';
|
||||
@@ -26,8 +25,8 @@ export default class LoggedIn extends React.Component {
|
||||
this.onUserChanged = this.onUserChanged.bind(this);
|
||||
this.setupUser = this.setupUser.bind(this);
|
||||
|
||||
// Initalize websockets
|
||||
Websockets.initialize();
|
||||
// Initalize websocket
|
||||
WebSocketActions.initialize();
|
||||
|
||||
// Force logout of all tabs if one tab is logged out
|
||||
$(window).bind('storage', (e) => {
|
||||
@@ -109,10 +108,6 @@ export default class LoggedIn extends React.Component {
|
||||
// Listen for user
|
||||
UserStore.addChangeListener(this.onUserChanged);
|
||||
|
||||
// Get all statuses regularally. (Soon to be switched to websocket)
|
||||
AsyncClient.getStatuses();
|
||||
this.intervalId = setInterval(() => AsyncClient.getStatuses(), CLIENT_STATUS_INTERVAL);
|
||||
|
||||
// ???
|
||||
$('body').on('mouseenter mouseleave', '.post', function mouseOver(ev) {
|
||||
if (ev.type === 'mouseenter') {
|
||||
@@ -144,7 +139,7 @@ export default class LoggedIn extends React.Component {
|
||||
}
|
||||
});
|
||||
|
||||
// Pervent backspace from navigating back a page
|
||||
// Prevent backspace from navigating back a page
|
||||
$(window).on('keydown.preventBackspace', (e) => {
|
||||
if (e.which === BACKSPACE_CHAR && !$(e.target).is('input, textarea')) {
|
||||
e.preventDefault();
|
||||
@@ -159,9 +154,8 @@ export default class LoggedIn extends React.Component {
|
||||
|
||||
componentWillUnmount() {
|
||||
$('#root').attr('class', '');
|
||||
clearInterval(this.intervalId);
|
||||
|
||||
Websockets.close();
|
||||
WebSocketActions.close();
|
||||
UserStore.removeChangeListener(this.onUserChanged);
|
||||
|
||||
$('body').off('click.userpopover');
|
||||
|
||||
@@ -125,7 +125,7 @@ export default class Sidebar extends React.Component {
|
||||
|
||||
directChannel.display_name = Utils.displayUsername(teammateId);
|
||||
directChannel.teammate_id = teammateId;
|
||||
directChannel.status = UserStore.getStatus(teammateId);
|
||||
directChannel.status = UserStore.getStatus(teammateId) || 'offline';
|
||||
|
||||
if (UserStore.hasTeamProfile(teammateId)) {
|
||||
directChannels.push(directChannel);
|
||||
|
||||
Ссылка в новой задаче
Block a user