Skip to content

Commit

Permalink
[IMPROVE] Add more fields to iframe integration event `unread-changed…
Browse files Browse the repository at this point in the history
…-by-subscription` (#15786)
  • Loading branch information
MarcosSpessatto authored and sampaiodiego committed Nov 21, 2019
1 parent ccd9f24 commit 6489774
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit 6489774

Please sign in to comment.