calculate badge count for tags as well

pull/21833/head
Bruno Windels 2019-02-06 11:02:12 +00:00
parent 7b367e267b
commit 77db3ca883
1 changed files with 10 additions and 1 deletions

View File

@ -15,6 +15,7 @@ limitations under the License.
*/
import {Store} from 'flux/utils';
import dis from '../dispatcher';
import * as RoomNotifs from '../RoomNotifs';
import RoomListStore from './RoomListStore';
const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/;
@ -63,6 +64,8 @@ class CustomRoomTagStore extends Store {
}
getSortedTags() {
const roomLists = RoomListStore.getRoomLists();
const tagNames = Object.keys(this._state.tags).sort();
const prefixes = tagNames.map((name, i) => {
const isFirst = i === 0;
@ -74,8 +77,14 @@ class CustomRoomTagStore extends Store {
return longestPrefix;
});
return tagNames.map((name, i) => {
const notifs = RoomNotifs.aggregateNotificationCount(roomLists[name]);
let badge;
if (notifs.count !== 0) {
badge = notifs;
}
const avatarLetter = name.substr(prefixes[i].length, 1);
return {name, selected: this._state.tags[name], avatarLetter};
const selected = this._state.tags[name];
return {name, avatarLetter, badge, selected};
});
}