summaryrefslogtreecommitdiffstats
path: root/webapp/stores/user_store.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-23 12:11:47 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-23 15:35:38 -0400
commitc3aa84a883dcb846d618c79571960fbaa5592056 (patch)
treea542957684df775f192b35b896b09066dd035973 /webapp/stores/user_store.jsx
parent7af2e6f87a754312809aa044edd062930616401a (diff)
downloadchat-c3aa84a883dcb846d618c79571960fbaa5592056.tar.gz
chat-c3aa84a883dcb846d618c79571960fbaa5592056.tar.bz2
chat-c3aa84a883dcb846d618c79571960fbaa5592056.zip
Fixing browser store issue.
Diffstat (limited to 'webapp/stores/user_store.jsx')
-rw-r--r--webapp/stores/user_store.jsx50
1 files changed, 20 insertions, 30 deletions
diff --git a/webapp/stores/user_store.jsx b/webapp/stores/user_store.jsx
index 98cc2f3f1..4213e6e8c 100644
--- a/webapp/stores/user_store.jsx
+++ b/webapp/stores/user_store.jsx
@@ -16,7 +16,10 @@ const CHANGE_EVENT_STATUSES = 'change_statuses';
class UserStoreClass extends EventEmitter {
constructor() {
super();
- this.profileCache = null;
+ this.profiles = {};
+ this.statuses = {};
+ this.sessions = {};
+ this.audits = {};
this.currentUserId = '';
}
@@ -135,11 +138,7 @@ class UserStoreClass extends EventEmitter {
}
getProfiles() {
- if (this.profileCache !== null) {
- return this.profileCache;
- }
-
- return BrowserStore.getItem('profiles', {});
+ return this.profiles;
}
getActiveOnlyProfiles(skipCurrent) {
@@ -171,47 +170,38 @@ class UserStoreClass extends EventEmitter {
}
saveProfile(profile) {
- var ps = this.getProfiles();
- ps[profile.id] = profile;
- this.profileCache = ps;
- BrowserStore.setItem('profiles', ps);
+ this.profiles[profile.id] = profile;
}
saveProfiles(profiles) {
const currentId = this.getCurrentId();
- if (this.profileCache) {
- const currentUser = this.profileCache[currentId];
- if (currentUser) {
- if (currentId in profiles) {
- delete profiles[currentId];
- }
-
- this.profileCache = profiles;
- this.profileCache[currentId] = currentUser;
- } else {
- this.profileCache = profiles;
+ const currentUser = this.profiles[currentId];
+ if (currentUser) {
+ if (currentId in this.profiles) {
+ delete this.profiles[currentId];
}
+
+ this.profiles = profiles;
+ this.profiles[currentId] = currentUser;
} else {
- this.profileCache = profiles;
+ this.profiles = profiles;
}
-
- BrowserStore.setItem('profiles', profiles);
}
setSessions(sessions) {
- BrowserStore.setItem('sessions', sessions);
+ this.sessions = sessions;
}
getSessions() {
- return BrowserStore.getItem('sessions', {loading: true});
+ return this.sessions;
}
setAudits(audits) {
- BrowserStore.setItem('audits', audits);
+ this.audits = audits;
}
getAudits() {
- return BrowserStore.getItem('audits', {loading: true});
+ return this.audits;
}
getCurrentMentionKeys() {
@@ -252,7 +242,7 @@ class UserStoreClass extends EventEmitter {
}
pSetStatuses(statuses) {
- BrowserStore.setItem('statuses', statuses);
+ this.statuses = statuses;
}
setStatus(userId, status) {
@@ -263,7 +253,7 @@ class UserStoreClass extends EventEmitter {
}
getStatuses() {
- return BrowserStore.getItem('statuses', {});
+ return this.statuses;
}
getStatus(id) {