summaryrefslogtreecommitdiffstats
path: root/web/react/stores/channel_store.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/stores/channel_store.jsx')
-rw-r--r--web/react/stores/channel_store.jsx64
1 files changed, 12 insertions, 52 deletions
diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx
index 4429a5312..4a27e5f17 100644
--- a/web/react/stores/channel_store.jsx
+++ b/web/react/stores/channel_store.jsx
@@ -16,6 +16,7 @@ var MORE_CHANGE_EVENT = 'change';
var EXTRA_INFO_EVENT = 'extra_info';
var ChannelStore = assign({}, EventEmitter.prototype, {
+ _current_id: null,
emitChange: function() {
this.emit(CHANGE_EVENT);
},
@@ -88,10 +89,7 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
return this._getMoreChannels();
},
setCurrentId: function(id) {
- if (id == null)
- BrowserStore.removeItem("current_channel_id");
- else
- BrowserStore.setItem("current_channel_id", id);
+ this._current_id = id;
},
setLastVisitedName: function(name) {
if (name == null)
@@ -117,10 +115,10 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
this._storeChannelMembers(cm);
},
getCurrentId: function() {
- return BrowserStore.getItem("current_channel_id");
+ return this._current_id;
},
getCurrent: function() {
- var currentId = ChannelStore.getCurrentId();
+ var currentId = this.getCurrentId();
if (currentId != null)
return this.get(currentId);
@@ -165,49 +163,22 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
return extra;
},
_storeChannels: function(channels) {
- BrowserStore.setItem("channels", JSON.stringify(channels));
+ BrowserStore.setItem("channels", channels);
},
_getChannels: function() {
- var channels = [];
- try {
- channels = JSON.parse(BrowserStore.getItem("channels"));
- }
- catch (err) {
- }
-
- if (channels == null) {
- channels = [];
- }
-
- return channels;
+ return BrowserStore.getItem("channels", []);
},
_storeChannelMembers: function(channelMembers) {
- BrowserStore.setItem("channel_members", JSON.stringify(channelMembers));
+ BrowserStore.setItem("channel_members", channelMembers);
},
_getChannelMembers: function() {
- var members = {};
- try {
- members = JSON.parse(BrowserStore.getItem("channel_members"));
- }
- catch (err) {
- }
-
- if (members == null) {
- members = {};
- }
-
- return members;
+ return BrowserStore.getItem("channel_members", {});
},
_storeMoreChannels: function(channels) {
- BrowserStore.setItem("more_channels", JSON.stringify(channels));
+ BrowserStore.setItem("more_channels", channels);
},
_getMoreChannels: function() {
- var channels = null;
- try {
- channels = JSON.parse(BrowserStore.getItem("more_channels"));
- }
- catch (err) {
- }
+ var channels = BrowserStore.getItem("more_channels");
if (channels == null) {
channels = {};
@@ -217,21 +188,10 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
return channels;
},
_storeExtraInfos: function(extraInfos) {
- BrowserStore.setItem("extra_infos", JSON.stringify(extraInfos));
+ BrowserStore.setItem("extra_infos", extraInfos);
},
_getExtraInfos: function() {
- var members = {};
- try {
- members = JSON.parse(BrowserStore.getItem("extra_infos"));
- }
- catch (err) {
- }
-
- if (members == null) {
- members = {};
- }
-
- return members;
+ return BrowserStore.getItem("extra_infos", {});
}
});