PLT-2707 Adding option to show DM list from all of server (#2871)

* PLT-2707 Adding option to show DM list from all of server

* Fixing loc
Этот коммит содержится в:
Corey Hulen
2016-05-04 06:31:42 -07:00
коммит произвёл Christopher Speller
родитель 6b06f49e89
Коммит 6611229cd7
29 изменённых файлов: 505 добавлений и 72 удалений

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

@@ -7,6 +7,7 @@ import EventEmitter from 'events';
import Constants from 'utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
const CHANGE_EVENT_DM_LIST = 'change_dm_list';
const CHANGE_EVENT = 'change';
const CHANGE_EVENT_SESSIONS = 'change_sessions';
const CHANGE_EVENT_AUDITS = 'change_audits';
@@ -19,6 +20,7 @@ class UserStoreClass extends EventEmitter {
}
clear() {
this.profiles_for_dm_list = {};
this.profiles = {};
this.direct_profiles = {};
this.statuses = {};
@@ -40,6 +42,18 @@ class UserStoreClass extends EventEmitter {
this.removeListener(CHANGE_EVENT, callback);
}
emitDmListChange() {
this.emit(CHANGE_EVENT_DM_LIST);
}
addDmListChangeListener(callback) {
this.on(CHANGE_EVENT_DM_LIST, callback);
}
removeDmListChangeListener(callback) {
this.removeListener(CHANGE_EVENT_DM_LIST, callback);
}
emitSessionsChange() {
this.emit(CHANGE_EVENT_SESSIONS);
}
@@ -190,6 +204,29 @@ class UserStoreClass extends EventEmitter {
}
}
getProfilesForDmList() {
const currentId = this.getCurrentId();
const profiles = [];
for (const id in this.profiles_for_dm_list) {
if (this.profiles_for_dm_list.hasOwnProperty(id) && id !== currentId) {
var profile = this.profiles_for_dm_list[id];
if (profile.delete_at === 0) {
profiles.push(profile);
}
}
}
profiles.sort((a, b) => a.username.localeCompare(b.username));
return profiles;
}
saveProfilesForDmList(profiles) {
this.profiles_for_dm_list = profiles;
}
setSessions(sessions) {
this.sessions = sessions;
}
@@ -278,6 +315,10 @@ UserStore.dispatchToken = AppDispatcher.register((payload) => {
var action = payload.action;
switch (action.type) {
case ActionTypes.RECEIVED_PROFILES_FOR_DM_LIST:
UserStore.saveProfilesForDmList(action.profiles);
UserStore.emitDmListChange();
break;
case ActionTypes.RECEIVED_PROFILES:
UserStore.saveProfiles(action.profiles);
UserStore.emitChange();