summaryrefslogtreecommitdiffstats
path: root/webapp/utils
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2017-05-12 08:00:28 -0400
committerJoramWilander <jwawilander@gmail.com>2017-05-12 08:00:28 -0400
commit9d109b070037951fcd0832b785eba8a3db9a157c (patch)
tree5d109da2e9e088f16eff0ad1421876a3d3da412e /webapp/utils
parentb1c39204a63a87d2cbc57f66cf9db50c938b2ee5 (diff)
parenta21a06afd9907e9911dcb166d902cba9f405c7cb (diff)
downloadchat-9d109b070037951fcd0832b785eba8a3db9a157c.tar.gz
chat-9d109b070037951fcd0832b785eba8a3db9a157c.tar.bz2
chat-9d109b070037951fcd0832b785eba8a3db9a157c.zip
Merge branch 'release-3.9' into merge-3.9
Diffstat (limited to 'webapp/utils')
-rw-r--r--webapp/utils/channel_utils.jsx25
-rw-r--r--webapp/utils/utils.jsx4
2 files changed, 27 insertions, 2 deletions
diff --git a/webapp/utils/channel_utils.jsx b/webapp/utils/channel_utils.jsx
index 10d06fbe1..1afce39b4 100644
--- a/webapp/utils/channel_utils.jsx
+++ b/webapp/utils/channel_utils.jsx
@@ -5,6 +5,8 @@ const Preferences = Constants.Preferences;
import * as Utils from 'utils/utils.jsx';
import UserStore from 'stores/user_store.jsx';
+import ChannelStore from 'stores/channel_store.jsx';
+import TeamStore from 'stores/team_store.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import LocalizationStore from 'stores/localization_store.jsx';
@@ -251,6 +253,29 @@ export function buildGroupChannelName(channelId) {
return displayName;
}
+export function getCountsStateFromStores(team = TeamStore.getCurrent(), teamMembers = TeamStore.getMyTeamMembers(), unreadCounts = ChannelStore.getUnreadCounts()) {
+ let mentionCount = 0;
+ let messageCount = 0;
+
+ teamMembers.forEach((member) => {
+ if (member.team_id !== TeamStore.getCurrentId()) {
+ mentionCount += (member.mention_count || 0);
+ messageCount += (member.msg_count || 0);
+ }
+ });
+
+ Object.keys(unreadCounts).forEach((chId) => {
+ const channel = ChannelStore.get(chId);
+
+ if (channel && (channel.type === Constants.DM_CHANNEL || channel.type === Constants.GM_CHANNEL || channel.team_id === team.id)) {
+ messageCount += unreadCounts[chId].msgs;
+ mentionCount += unreadCounts[chId].mentions;
+ }
+ });
+
+ return {mentionCount, messageCount};
+}
+
/*
* not exported helpers
*/
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index 9e5d23252..3404a0b82 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -558,13 +558,13 @@ export function applyTheme(theme) {
if (theme.mentionBj) {
changeCss('.sidebar--left .nav-pills__unread-indicator, .app__body .new-messages__button div', 'background:' + theme.mentionBj);
- changeCss('.sidebar--left .badge', 'background:' + theme.mentionBj + ' !important');
+ changeCss('.app__body .sidebar--left .badge', 'background:' + theme.mentionBj);
changeCss('.multi-teams .team-sidebar .team-wrapper .team-container .team-btn .badge', 'background:' + theme.mentionBj + ' !important');
}
if (theme.mentionColor) {
changeCss('.app__body .sidebar--left .nav-pills__unread-indicator, .app__body .new-messages__button div', 'color:' + theme.mentionColor);
- changeCss('.app__body .sidebar--left .badge', 'color:' + theme.mentionColor + ' !important');
+ changeCss('.app__body .sidebar--left .badge', 'color:' + theme.mentionColor);
changeCss('.app__body .multi-teams .team-sidebar .team-wrapper .team-container .team-btn .badge', 'color:' + theme.mentionColor + ' !important');
}