From 1a75800dd8d09e9b001a71913b76f005eaa1df2b Mon Sep 17 00:00:00 2001 From: Mario Jr Date: Wed, 10 Mar 2021 16:22:16 -0300 Subject: [PATCH] Observe both added and changed events when user joins Depending on the sequence of events on the server, user sometimes is added to the users collection with the name information, and sometimes this information is updated in a second moment. Once we need the username to show the push notification, we observe changes on this field for both added and changed event. Closes #11307 --- .../imports/startup/client/base.jsx | 73 +++++++++++-------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/bigbluebutton-html5/imports/startup/client/base.jsx b/bigbluebutton-html5/imports/startup/client/base.jsx index bae3c9cd41..c471e70948 100755 --- a/bigbluebutton-html5/imports/startup/client/base.jsx +++ b/bigbluebutton-html5/imports/startup/client/base.jsx @@ -64,6 +64,45 @@ class Base extends Component { } } + /** + * Callback for handling changes on users collection. + * Depending on what are the changes, we show the alerts. + * for more information see: + * https://docs.meteor.com/api/collections.html#Mongo-Cursor-observeChanges + */ + static handleUserJoinAlert(id, userFields) { + const subscriptionsReady = Session.get('subscriptionsReady'); + + if (!subscriptionsReady || !userFields.name) return; + + const { + userJoinAudioAlerts, + userJoinPushAlerts, + } = Settings.application; + + if (!userJoinAudioAlerts && !userJoinPushAlerts) return; + + if (userJoinAudioAlerts) { + AudioService.playAlertSound(`${Meteor.settings.public.app.cdn + + Meteor.settings.public.app.basename}` + + '/resources/sounds/userJoin.mp3'); + } + + if (userJoinPushAlerts) { + notify( + , + 'info', + 'user', + ); + } + } + constructor(props) { super(props); @@ -96,38 +135,8 @@ class Base extends Component { }, { fields: { name: 1, userId: 1 } }); users.observeChanges({ - changed: (id, userFields) => { - const subscriptionsReady = Session.get('subscriptionsReady'); - - if (!subscriptionsReady || !userFields.name) return; - - const { - userJoinAudioAlerts, - userJoinPushAlerts, - } = Settings.application; - - if (!userJoinAudioAlerts && !userJoinPushAlerts) return; - - if (userJoinAudioAlerts) { - AudioService.playAlertSound(`${Meteor.settings.public.app.cdn - + Meteor.settings.public.app.basename}` - + '/resources/sounds/userJoin.mp3'); - } - - if (userJoinPushAlerts) { - notify( - , - 'info', - 'user', - ); - } - }, + added: Base.handleUserJoinAlert, + changed: Base.handleUserJoinAlert, }); }