summaryrefslogtreecommitdiffstats
path: root/web/react/stores/channel_store.jsx
diff options
context:
space:
mode:
authorralder <ralder@yandex.ru>2015-07-15 09:03:28 -0700
committerralder <ralder@yandex.ru>2015-07-16 07:20:48 -0700
commit56db6ad08cf23dbdcee326fa39bda8bcdcdecf9e (patch)
treed5df6a7058441d1fdff2d6f7bb47aeacf86f6765 /web/react/stores/channel_store.jsx
parentb236079d936e7f7af648b362d11b491fc0a2c428 (diff)
downloadchat-56db6ad08cf23dbdcee326fa39bda8bcdcdecf9e.tar.gz
chat-56db6ad08cf23dbdcee326fa39bda8bcdcdecf9e.tar.bz2
chat-56db6ad08cf23dbdcee326fa39bda8bcdcdecf9e.zip
remove admin's ability to manage members of default channel (fixes #172)
Diffstat (limited to 'web/react/stores/channel_store.jsx')
-rw-r--r--web/react/stores/channel_store.jsx53
1 files changed, 20 insertions, 33 deletions
diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx
index 4a27e5f17..a97f13391 100644
--- a/web/react/stores/channel_store.jsx
+++ b/web/react/stores/channel_store.jsx
@@ -44,40 +44,24 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
removeExtraInfoChangeListener: function(callback) {
this.removeListener(EXTRA_INFO_EVENT, callback);
},
- get: function(id) {
- var current = null;
- var c = this._getChannels();
-
- c.some(function(channel) {
- if (channel.id == id) {
- current = channel;
- return true;
+ findFirstBy: function(field, value) {
+ var channels = this._getChannels();
+ for (var i = 0; i < channels.length; i++) {
+ if (channels[i][field] == value) {
+ return channels[i];
}
- return false;
- });
+ }
- return current;
+ return null;
+ },
+ get: function(id) {
+ return this.findFirstBy('id', id);
},
getMember: function(id) {
- var current = null;
return this.getAllMembers()[id];
},
getByName: function(name) {
- var current = null;
- var c = this._getChannels();
-
- c.some(function(channel) {
- if (channel.name == name) {
- current = channel;
- return true;
- }
-
- return false;
-
- });
-
- return current;
-
+ return this.findFirstBy('name', name);
},
getAll: function() {
return this._getChannels();
@@ -120,7 +104,7 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
getCurrent: function() {
var currentId = this.getCurrentId();
- if (currentId != null)
+ if (currentId)
return this.get(currentId);
else
return null;
@@ -128,7 +112,7 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
getCurrentMember: function() {
var currentId = ChannelStore.getCurrentId();
- if (currentId != null)
+ if (currentId)
return this.getAllMembers()[currentId];
else
return null;
@@ -143,7 +127,7 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
var currentId = ChannelStore.getCurrentId();
var extra = null;
- if (currentId != null)
+ if (currentId)
extra = this._getExtraInfos()[currentId];
if (extra == null)
@@ -154,7 +138,7 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
getExtraInfo: function(channel_id) {
var extra = null;
- if (channel_id != null)
+ if (channel_id)
extra = this._getExtraInfos()[channel_id];
if (extra == null)
@@ -192,7 +176,10 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
},
_getExtraInfos: function() {
return BrowserStore.getItem("extra_infos", {});
- }
+ },
+ isDefault: function(channel) {
+ return channel.name == Constants.DEFAULT_CHANNEL;
+ }
});
ChannelStore.dispatchToken = AppDispatcher.register(function(payload) {
@@ -231,4 +218,4 @@ ChannelStore.dispatchToken = AppDispatcher.register(function(payload) {
}
});
-module.exports = ChannelStore;
+module.exports = ChannelStore; \ No newline at end of file