summaryrefslogtreecommitdiffstats
path: root/webapp/stores
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-05-04 06:31:42 -0700
committerChristopher Speller <crspeller@gmail.com>2016-05-04 09:31:42 -0400
commit6611229cd7bd3cdfc0082c0a581145aaac0ab322 (patch)
treedb6670a8c2716179bfe6e07b82588d83d3afb6bd /webapp/stores
parent6b06f49e8910ed44f619adad15ab268758312852 (diff)
downloadchat-6611229cd7bd3cdfc0082c0a581145aaac0ab322.tar.gz
chat-6611229cd7bd3cdfc0082c0a581145aaac0ab322.tar.bz2
chat-6611229cd7bd3cdfc0082c0a581145aaac0ab322.zip
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
Diffstat (limited to 'webapp/stores')
-rw-r--r--webapp/stores/user_store.jsx41
1 files changed, 41 insertions, 0 deletions
diff --git a/webapp/stores/user_store.jsx b/webapp/stores/user_store.jsx
index 8d685aea3..5a27d15ea 100644
--- a/webapp/stores/user_store.jsx
+++ b/webapp/stores/user_store.jsx
@@ -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();