Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client/startup/unread.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session';

import { Favico } from '../../app/favico';
import { ChatSubscription } from '../../app/models';
import { ChatSubscription, ChatRoom } from '../../app/models/client';
import { menu, fireGlobalEvent } from '../../app/ui-utils';
import { getUserPreference } from '../../app/utils';
import { settings } from '../../app/settings';
Expand All @@ -20,6 +20,8 @@ const fetchSubscriptions = () => ChatSubscription.find({
name: 1,
ls: 1,
unreadAlert: 1,
fname: 1,
prid: 1,
},
}).fetch();

Expand All @@ -30,7 +32,8 @@ Meteor.startup(() => {
let unreadAlert = false;

const unreadCount = fetchSubscriptions().reduce((ret, subscription) => {
fireGlobalEvent('unread-changed-by-subscription', subscription);
const room = ChatRoom.findOne({ _id: subscription.rid }, { fields: { usersCount: 1 } });
fireGlobalEvent('unread-changed-by-subscription', { ...subscription, usersCount: room && room.usersCount });

if (subscription.alert || subscription.unread > 0) {
// Increment the total unread count.
Expand Down
1 change: 1 addition & 0 deletions server/publications/room/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const fields = {
lastMessage: 1,
retention: 1,
prid: 1,
usersCount: 1,

// @TODO create an API to register this fields based on room type
livechatData: 1,
Expand Down