Merging performance branch into master (#4268)

* improve performance on sendNotifications

* Fix SQL queries

* Remove get direct profiles, not needed anymore

* Add raw data to error details if AppError fails to decode

* men

* Fix decode (#4052)

* Fixing json decode

* Adding unit test

* Initial work for client scaling (#4051)

* Begin adding paging to profiles API

* Added more paging functionality

* Finish hooking up admin console user lists

* Add API for searching users and add searching to all user lists

* Add lazy loading of profiles

* Revert config.json

* Fix unit tests and some style issues

* Add GetProfilesFromList to Go driver and fix web unit test

* Update etag for GetProfiles

* Updating ui for filters and pagination (#4044)

* Updating UI for pagination

* Adjusting margins for filter row

* Adjusting margin for specific modals

* Adding relative padding to system console

* Adjusting responsive view

* Update client user tests

* Minor fixes for direct messages modal (#4056)

* Remove some unneeded initial load calls (#4057)

* UX updates to user lists, added smart counts and bug fixes (#4059)

* Improved getExplicitMentions and unit tests (#4064)

* Refactor getting posts to lazy load profiles correctly (#4062)

* Comment out SetActiveChannel test (#4066)

* Profiler cpu, block, and memory profiler. (#4081)

* Fix TestSetActiveChannel unit test (#4071)

* Fixing build failure caused by dependancies updating (#4076)

* Adding profiler

* Fix admin_team_member_dropdown eslint errors

* Bumping session cache size (#4077)

* Bumping session cache size

* Bumping status cache

* Refactor how the client handles channel members to be large team friendly (#4106)

* Refactor how the client handles channel members to be large team friendly

* Change Id to ChannelId in ChannelStats model

* Updated getChannelMember and getProfilesByIds routes to match proposal

* Performance improvements (#4100)

* Performance improvements

* Fixing re-connect issue

* Fixing error message

* Some other minor perf tweaks

* Some other minor perf tweaks

* Fixing config file

* Fixing buffer size

* Fixing web socket send message

* adding some error logging

* fix getMe to be user required

* Fix websocket event for new user

* Fixing shutting down

* Reverting web socket changes

* Fixing logging lvl

* Adding caching to GetMember

* Adding some logging

* Fixing caching

* Fixing caching invalidate

* Fixing direct message caching

* Fixing caching

* Fixing caching

* Remove GetDirectProfiles from initial load

* Adding logging and fixing websocket client

* Adding back caching from bad merge.

* Explicitly close go driver requests (#4162)

* Refactored how the client handles team members to be more large team friendly (#4159)

* Refactor getProfilesForDirectMessageList API into getAllProfiles API

* Refactored how the client handles team members to be more large team friendly

* Fix js error when receiving a notification

* Fix JS error caused by current user being overwritten with sanitized version (#4165)

* Adding error message to status failure (#4167)

* Fix a few bugs caused by client scaling refactoring (#4170)

* When there is no read replica, don't open a second set of connections to the master database (#4173)

* Adding connection tacking to stats (#4174)

* Reduce DB writes for statuses and other status related changes (#4175)

* Fix bug preventing opening of DM channels from more modal (#4181)

* 	Fixing socket timing error (#4183)

* Fixing ping/pong handler

* Fixing socket timing error

* Commenting out status broadcasting

* Removing user status changes

* Removing user status changes

* Removing user status changes

* Removing user status changes

* Adding DoPreComputeJson()

* Performance improvements (#4194)

* * Fix System Console Analytics queries
* Add db.SetConnMaxLifetime to 15 minutes
* Add "net/http/pprof" for profiling
* Add FreeOSMemory() to manually release memory on reload config

* Add flag to enable http profiler

* Fix memory leak (#4197)

* Fix memory leak

* removed unneeded nil assignment

* Fixing go routine leak (#4208)

* Merge fixes

* Merge fix

* Refactored statuses to be queried by the client rather than broadcast by the server (#4212)

* Refactored server code to reduce status broadcasts and to allow getting statuses by IDs

* Refactor client code to periodically fetch statuses

* Add store unit test for getting statuses by ids

* Fix status unit test

* Add getStatusesByIds REST API and move the client over to use that instead of the WebSocket

* Adding multiple threads to websocket hub (#4230)

* Adding multiple threads to websocket hub

* Fixing unit tests

* Fixing so websocket connections from the same user end up in the same… (#4240)

* Fixing so websocket connections from the same user end up in the same list

* Removing old comment

* Refactor user autocomplete to query the server (#4239)

* Add API for autocompleting users

* Converted at mention autocomplete to query server

* Converted user search autocomplete to query server

* Switch autocomplete API naming to use term instead of username

* Split autocomplete API into two, one for channels and for teams

* Fix copy/paste error

* Some final client scaling fixes (#4246)

* Add lazy loading of profiles to integration pages

* Add lazy loading of profiles to emoji page

* Fix JS error when receiving post in select team menu and also clean up channel store
Этот коммит содержится в:
Joram Wilander
2016-10-19 14:49:25 -04:00
коммит произвёл GitHub
родитель 0512bd26ee
Коммит 365b8b465e
129 изменённых файлов: 6411 добавлений и 2530 удалений

Просмотреть файл

@@ -1,19 +1,21 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import $ from 'jquery';
import Client from 'client/web_client.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import PostStore from 'stores/post_store.jsx';
import UserStore from 'stores/user_store.jsx';
import * as utils from './utils.jsx';
import * as UserAgent from './user_agent.jsx';
import TeamStore from 'stores/team_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
import Constants from './constants.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import Client from 'client/web_client.jsx';
import * as utils from 'utils/utils.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
import Constants from 'utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
const StatTypes = Constants.StatTypes;
@@ -215,94 +217,89 @@ export function getMoreChannels(force) {
}
}
export function getChannelExtraInfo(id, memberLimit) {
let channelId;
if (id) {
channelId = id;
} else {
channelId = ChannelStore.getCurrentId();
}
if (channelId != null) {
if (isCallInProgress('getChannelExtraInfo_' + channelId)) {
return;
}
callTracker['getChannelExtraInfo_' + channelId] = utils.getTimestamp();
Client.getChannelExtraInfo(
channelId,
memberLimit,
(data) => {
callTracker['getChannelExtraInfo_' + channelId] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_CHANNEL_EXTRA_INFO,
extra_info: data
});
},
(err) => {
callTracker['getChannelExtraInfo_' + channelId] = 0;
dispatchError(err, 'getChannelExtraInfo');
}
);
}
}
export function getTeamMembers(teamId) {
if (isCallInProgress('getTeamMembers')) {
export function getChannelStats(channelId = ChannelStore.getCurrentId()) {
if (isCallInProgress('getChannelStats' + channelId)) {
return;
}
callTracker.getTeamMembers = utils.getTimestamp();
Client.getTeamMembers(
teamId,
callTracker['getChannelStats' + channelId] = utils.getTimestamp();
Client.getChannelStats(
channelId,
(data) => {
callTracker.getTeamMembers = 0;
callTracker['getChannelStats' + channelId] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_MEMBERS_FOR_TEAM,
team_members: data
type: ActionTypes.RECEIVED_CHANNEL_STATS,
stats: data
});
},
(err) => {
callTracker.getTeamMembers = 0;
dispatchError(err, 'getTeamMembers');
callTracker['getChannelStats' + channelId] = 0;
dispatchError(err, 'getChannelStats');
}
);
}
export function getProfilesForDirectMessageList() {
if (isCallInProgress('getProfilesForDirectMessageList')) {
export function getChannelMember(channelId, userId) {
if (isCallInProgress(`getChannelMember${channelId}${userId}`)) {
return;
}
callTracker.getProfilesForDirectMessageList = utils.getTimestamp();
Client.getProfilesForDirectMessageList(
callTracker[`getChannelMember${channelId}${userId}`] = utils.getTimestamp();
Client.getChannelMember(
channelId,
userId,
(data) => {
callTracker.getProfilesForDirectMessageList = 0;
callTracker[`getChannelMember${channelId}${userId}`] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_PROFILES_FOR_DM_LIST,
profiles: data
type: ActionTypes.RECEIVED_CHANNEL_MEMBER,
member: data
});
},
(err) => {
callTracker.getProfilesForDirectMessageList = 0;
dispatchError(err, 'getProfilesForDirectMessageList');
callTracker[`getChannelMember${channelId}${userId}`] = 0;
dispatchError(err, 'getChannelMember');
}
);
}
export function getProfiles() {
if (isCallInProgress('getProfiles')) {
export function getUser(userId) {
if (isCallInProgress(`getUser${userId}`)) {
return;
}
callTracker.getProfiles = utils.getTimestamp();
callTracker[`getUser${userId}`] = utils.getTimestamp();
Client.getUser(
userId,
(data) => {
callTracker[`getUser${userId}`] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_PROFILE,
profile: data
});
},
(err) => {
callTracker[`getUser${userId}`] = 0;
dispatchError(err, 'getUser');
}
);
}
export function getProfiles(offset = UserStore.getPagingOffset(), limit = Constants.PROFILE_CHUNK_SIZE) {
if (isCallInProgress(`getProfiles${offset}${limit}`)) {
return;
}
callTracker[`getProfiles${offset}${limit}`] = utils.getTimestamp();
Client.getProfiles(
offset,
limit,
(data) => {
callTracker.getProfiles = 0;
callTracker[`getProfiles${offset}${limit}`] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_PROFILES,
@@ -310,30 +307,123 @@ export function getProfiles() {
});
},
(err) => {
callTracker.getProfiles = 0;
callTracker[`getProfiles${offset}${limit}`] = 0;
dispatchError(err, 'getProfiles');
}
);
}
export function getDirectProfiles() {
if (isCallInProgress('getDirectProfiles')) {
export function getProfilesInTeam(teamId = TeamStore.getCurrentId(), offset = UserStore.getInTeamPagingOffset(), limit = Constants.PROFILE_CHUNK_SIZE) {
if (isCallInProgress(`getProfilesInTeam${offset}${limit}`)) {
return;
}
callTracker.getDirectProfiles = utils.getTimestamp();
Client.getDirectProfiles(
callTracker[`getProfilesInTeam${offset}${limit}`] = utils.getTimestamp();
Client.getProfilesInTeam(
teamId,
offset,
limit,
(data) => {
callTracker.getDirectProfiles = 0;
callTracker[`getProfilesInTeam${offset}${limit}`] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_DIRECT_PROFILES,
type: ActionTypes.RECEIVED_PROFILES_IN_TEAM,
profiles: data,
team_id: teamId,
offset,
count: Object.keys(data).length
});
},
(err) => {
callTracker[`getProfilesInTeam${offset}${limit}`] = 0;
dispatchError(err, 'getProfilesInTeam');
}
);
}
export function getProfilesInChannel(channelId = ChannelStore.getCurrentId(), offset = UserStore.getInChannelPagingOffset(), limit = Constants.PROFILE_CHUNK_SIZE) {
if (isCallInProgress(`getProfilesInChannel${offset}${limit}`)) {
return;
}
callTracker[`getProfilesInChannel${offset}${limit}`] = utils.getTimestamp();
Client.getProfilesInChannel(
channelId,
offset,
limit,
(data) => {
callTracker[`getProfilesInChannel${offset}${limit}`] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_PROFILES_IN_CHANNEL,
channel_id: channelId,
profiles: data,
offset,
count: Object.keys(data).length
});
loadStatusesForProfilesMap(data);
},
(err) => {
callTracker[`getProfilesInChannel${offset}${limit}`] = 0;
dispatchError(err, 'getProfilesInChannel');
}
);
}
export function getProfilesNotInChannel(channelId = ChannelStore.getCurrentId(), offset = UserStore.getNotInChannelPagingOffset(), limit = Constants.PROFILE_CHUNK_SIZE) {
if (isCallInProgress(`getProfilesNotInChannel${offset}${limit}`)) {
return;
}
callTracker[`getProfilesNotInChannel${offset}${limit}`] = utils.getTimestamp();
Client.getProfilesNotInChannel(
channelId,
offset,
limit,
(data) => {
callTracker[`getProfilesNotInChannel${offset}${limit}`] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_PROFILES_NOT_IN_CHANNEL,
channel_id: channelId,
profiles: data,
offset,
count: Object.keys(data).length
});
loadStatusesForProfilesMap(data);
},
(err) => {
callTracker[`getProfilesNotInChannel${offset}${limit}`] = 0;
dispatchError(err, 'getProfilesNotInChannel');
}
);
}
export function getProfilesByIds(userIds) {
if (isCallInProgress('getProfilesByIds')) {
return;
}
if (!userIds || userIds.length === 0) {
return;
}
callTracker.getProfilesByIds = utils.getTimestamp();
Client.getProfilesByIds(
userIds,
(data) => {
callTracker.getProfilesByIds = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_PROFILES,
profiles: data
});
},
(err) => {
callTracker.getDirectProfiles = 0;
dispatchError(err, 'getDirectProfiles');
callTracker.getProfilesByIds = 0;
dispatchError(err, 'getProfilesByIds');
}
);
}
@@ -548,173 +638,6 @@ export function search(terms, isOrSearch) {
);
}
export function getPostsPage(id, maxPosts) {
let channelId = id;
if (channelId == null) {
channelId = ChannelStore.getCurrentId();
if (channelId == null) {
return;
}
}
if (isCallInProgress('getPostsPage_' + channelId)) {
return;
}
var postList = PostStore.getAllPosts(id);
var max = maxPosts;
if (max == null) {
max = Constants.POST_CHUNK_SIZE * Constants.MAX_POST_CHUNKS;
}
// if we already have more than POST_CHUNK_SIZE posts,
// let's get the amount we have but rounded up to next multiple of POST_CHUNK_SIZE,
// with a max at maxPosts
var numPosts = Math.min(max, Constants.POST_CHUNK_SIZE);
if (postList && postList.order.length > 0) {
numPosts = Math.min(max, Constants.POST_CHUNK_SIZE * Math.ceil(postList.order.length / Constants.POST_CHUNK_SIZE));
}
if (channelId != null) {
callTracker['getPostsPage_' + channelId] = utils.getTimestamp();
Client.getPostsPage(
channelId,
0,
numPosts,
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_POSTS,
id: channelId,
before: true,
numRequested: numPosts,
checkLatest: true,
post_list: data
});
},
(err) => {
dispatchError(err, 'getPostsPage');
},
() => {
callTracker['getPostsPage_' + channelId] = 0;
}
);
}
}
export function getPosts(id) {
let channelId = id;
if (channelId == null) {
channelId = ChannelStore.getCurrentId();
if (channelId == null) {
return;
}
}
if (isCallInProgress('getPosts_' + channelId)) {
return;
}
const postList = PostStore.getAllPosts(channelId);
const latestPostTime = PostStore.getLatestPostFromPageTime(id);
if ($.isEmptyObject(postList) || postList.order.length < Constants.POST_CHUNK_SIZE || latestPostTime === 0) {
getPostsPage(channelId, Constants.POST_CHUNK_SIZE);
return;
}
callTracker['getPosts_' + channelId] = utils.getTimestamp();
Client.getPosts(
channelId,
latestPostTime,
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_POSTS,
id: channelId,
before: true,
numRequested: 0,
post_list: data
});
},
(err) => {
dispatchError(err, 'getPosts');
},
() => {
callTracker['getPosts_' + channelId] = 0;
}
);
}
export function getPostsBefore(postId, offset, numPost, isPost) {
const channelId = ChannelStore.getCurrentId();
if (channelId == null) {
return;
}
if (isCallInProgress('getPostsBefore_' + channelId)) {
return;
}
Client.getPostsBefore(
channelId,
postId,
offset,
numPost,
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_POSTS,
id: channelId,
before: true,
numRequested: numPost,
post_list: data,
isPost
});
},
(err) => {
dispatchError(err, 'getPostsBefore');
},
() => {
callTracker['getPostsBefore_' + channelId] = 0;
}
);
}
export function getPostsAfter(postId, offset, numPost, isPost) {
const channelId = ChannelStore.getCurrentId();
if (channelId == null) {
return;
}
if (isCallInProgress('getPostsAfter_' + channelId)) {
return;
}
Client.getPostsAfter(
channelId,
postId,
offset,
numPost,
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_POSTS,
id: channelId,
before: false,
numRequested: numPost,
post_list: data,
isPost
});
},
(err) => {
dispatchError(err, 'getPostsAfter');
},
() => {
callTracker['getPostsAfter_' + channelId] = 0;
}
);
}
export function getFileInfosForPost(channelId, postId) {
const callName = 'getFileInfosForPost' + postId;
@@ -828,6 +751,58 @@ export function getMyTeam() {
);
}
export function getTeamMember(teamId, userId) {
const callName = `getTeamMember${teamId}${userId}`;
if (isCallInProgress(callName)) {
return;
}
callTracker[callName] = utils.getTimestamp();
Client.getTeamMember(
(data) => {
callTracker[callName] = 0;
const memberMap = {};
memberMap[userId] = data;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_MEMBERS_IN_TEAM,
team_id: teamId,
team_members: memberMap
});
},
(err) => {
callTracker[callName] = 0;
dispatchError(err, 'getTeamMember');
}
);
}
export function getTeamStats(teamId) {
const callName = `getTeamStats${teamId}`;
if (isCallInProgress(callName)) {
return;
}
callTracker[callName] = utils.getTimestamp();
Client.getTeamStats(
teamId,
(data) => {
callTracker[callName] = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_TEAM_STATS,
team_id: teamId,
stats: data
});
},
(err) => {
callTracker[callName] = 0;
dispatchError(err, 'getTeamStats');
}
);
}
export function getAllPreferences() {
if (isCallInProgress('getAllPreferences')) {
return;
@@ -987,6 +962,18 @@ export function getStandardAnalytics(teamId) {
if (data[index].name === 'team_count' && teamId == null) {
stats[StatTypes.TOTAL_TEAMS] = data[index].value;
}
if (data[index].name === 'total_websocket_connections') {
stats[StatTypes.TOTAL_WEBSOCKET_CONNECTIONS] = data[index].value;
}
if (data[index].name === 'total_master_db_connections') {
stats[StatTypes.TOTAL_MASTER_DB_CONNECTIONS] = data[index].value;
}
if (data[index].name === 'total_read_db_connections') {
stats[StatTypes.TOTAL_READ_DB_CONNECTIONS] = data[index].value;
}
}
AppDispatcher.handleServerAction({
@@ -1212,54 +1199,6 @@ export function getRecentAndNewUsersAnalytics(teamId) {
);
}
export function listIncomingHooks() {
if (isCallInProgress('listIncomingHooks')) {
return;
}
callTracker.listIncomingHooks = utils.getTimestamp();
Client.listIncomingHooks(
(data) => {
callTracker.listIncomingHooks = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_INCOMING_WEBHOOKS,
teamId: Client.teamId,
incomingWebhooks: data
});
},
(err) => {
callTracker.listIncomingHooks = 0;
dispatchError(err, 'getIncomingHooks');
}
);
}
export function listOutgoingHooks() {
if (isCallInProgress('listOutgoingHooks')) {
return;
}
callTracker.listOutgoingHooks = utils.getTimestamp();
Client.listOutgoingHooks(
(data) => {
callTracker.listOutgoingHooks = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_OUTGOING_WEBHOOKS,
teamId: Client.teamId,
outgoingWebhooks: data
});
},
(err) => {
callTracker.listOutgoingHooks = 0;
dispatchError(err, 'getOutgoingHooks');
}
);
}
export function addIncomingHook(hook, success, error) {
Client.addIncomingHook(
hook,
@@ -1353,30 +1292,6 @@ export function regenOutgoingHookToken(id) {
);
}
export function listTeamCommands() {
if (isCallInProgress('listTeamCommands')) {
return;
}
callTracker.listTeamCommands = utils.getTimestamp();
Client.listTeamCommands(
(data) => {
callTracker.listTeamCommands = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_COMMANDS,
teamId: Client.teamId,
commands: data
});
},
(err) => {
callTracker.listTeamCommands = 0;
dispatchError(err, 'listTeamCommands');
}
);
}
export function addCommand(command, success, error) {
Client.addCommand(
command,
@@ -1459,29 +1374,6 @@ export function getPublicLink(fileId, success, error) {
);
}
export function listEmoji() {
if (isCallInProgress('listEmoji')) {
return;
}
callTracker.listEmoji = utils.getTimestamp();
Client.listEmoji(
(data) => {
callTracker.listEmoji = 0;
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_CUSTOM_EMOJIS,
emojis: data
});
},
(err) => {
callTracker.listEmoji = 0;
dispatchError(err, 'listEmoji');
}
);
}
export function addEmoji(emoji, image, success, error) {
const callName = 'addEmoji' + emoji.name;

Просмотреть файл

@@ -71,7 +71,7 @@ export const ActionTypes = keyMirror({
RECEIVED_CHANNELS: null,
RECEIVED_CHANNEL: null,
RECEIVED_MORE_CHANNELS: null,
RECEIVED_CHANNEL_EXTRA_INFO: null,
RECEIVED_CHANNEL_STATS: null,
FOCUS_POST: null,
RECEIVED_POSTS: null,
@@ -84,9 +84,11 @@ export const ActionTypes = keyMirror({
RECEIVED_MENTION_DATA: null,
RECEIVED_ADD_MENTION: null,
RECEIVED_PROFILES_FOR_DM_LIST: null,
RECEIVED_PROFILES: null,
RECEIVED_DIRECT_PROFILES: null,
RECEIVED_PROFILES_IN_TEAM: null,
RECEIVED_PROFILE: null,
RECEIVED_PROFILES_IN_CHANNEL: null,
RECEIVED_PROFILE_NOT_IN_CHANNEL: null,
RECEIVED_ME: null,
RECEIVED_SESSIONS: null,
RECEIVED_AUDITS: null,
@@ -129,8 +131,9 @@ export const ActionTypes = keyMirror({
RECEIVED_SERVER_COMPLIANCE_REPORTS: null,
RECEIVED_ALL_TEAMS: null,
RECEIVED_ALL_TEAM_LISTINGS: null,
RECEIVED_TEAM_MEMBERS: null,
RECEIVED_MEMBERS_FOR_TEAM: null,
RECEIVED_MY_TEAM_MEMBERS: null,
RECEIVED_MEMBERS_IN_TEAM: null,
RECEIVED_TEAM_STATS: null,
RECEIVED_LOCALE: null,
@@ -232,7 +235,10 @@ export const Constants = {
POST_PER_DAY: null,
USERS_WITH_POSTS_PER_DAY: null,
RECENTLY_ACTIVE_USERS: null,
NEWLY_CREATED_USERS: null
NEWLY_CREATED_USERS: null,
TOTAL_WEBSOCKET_CONNECTIONS: null,
TOTAL_MASTER_DB_CONNECTIONS: null,
TOTAL_READ_DB_CONNECTIONS: null
}),
STAT_MAX_ACTIVE_USERS: 20,
STAT_MAX_NEW_USERS: 20,
@@ -313,7 +319,7 @@ export const Constants = {
SIGNIN_VERIFIED: 'verified',
SESSION_EXPIRED: 'expired',
POST_CHUNK_SIZE: 60,
MAX_POST_CHUNKS: 3,
PROFILE_CHUNK_SIZE: 100,
POST_FOCUS_CONTEXT_RADIUS: 10,
POST_LOADING: 'loading',
POST_FAILED: 'failed',
@@ -843,7 +849,9 @@ export const Constants = {
MENTION_MEMBERS: 'mention.members',
MENTION_NONMEMBERS: 'mention.nonmembers',
MENTION_SPECIAL: 'mention.special',
DEFAULT_NOTIFICATION_DURATION: 5000
DEFAULT_NOTIFICATION_DURATION: 5000,
STATUS_INTERVAL: 60000,
AUTOCOMPLETE_TIMEOUT: 200
};
export default Constants;

Просмотреть файл

@@ -10,7 +10,6 @@ import PreferenceStore from 'stores/preference_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import Constants from 'utils/constants.jsx';
var ActionTypes = Constants.ActionTypes;
import * as AsyncClient from './async_client.jsx';
import Client from 'client/web_client.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
@@ -1074,66 +1073,6 @@ export function windowHeight() {
return $(window).height();
}
export function openDirectChannelToUser(user, successCb, errorCb) {
AsyncClient.savePreference(
Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW,
user.id,
'true'
);
// if the user in another team and isn't already in the direct message
// list then we should add him so his name shows up correctly.
var profileUser = UserStore.getProfile(user.id);
if (!profileUser) {
UserStore.getDirectProfiles()[user.id] = user;
}
const channelName = this.getDirectChannelName(UserStore.getCurrentId(), user.id);
let channel = ChannelStore.getByName(channelName);
if (channel) {
if ($.isFunction(successCb)) {
successCb(channel, true);
}
} else {
channel = {
name: channelName,
last_post_at: 0,
total_msg_count: 0,
type: 'D',
display_name: user.username,
teammate_id: user.id,
status: UserStore.getStatus(user.id)
};
Client.createDirectChannel(
user.id,
(data) => {
Client.getChannel(
data.id,
(data2) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_CHANNEL,
channel: data2.channel,
member: data2.member
});
if ($.isFunction(successCb)) {
successCb(data2.channel, false);
}
}
);
},
() => {
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/' + channelName);
if ($.isFunction(errorCb)) {
errorCb();
}
}
);
}
}
// Use when sorting multiple channels or teams by their `display_name` field
export function sortByDisplayName(a, b) {
let aDisplayName = '';