Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Notify with sound first message in queue list #21969

Merged
merged 10 commits into from
May 17, 2021
18 changes: 18 additions & 0 deletions app/livechat/client/lib/stream/queueManager.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import { Meteor } from 'meteor/meteor';

import { APIClient } from '../../../../utils/client';
import { LivechatInquiry } from '../../collections/LivechatInquiry';
import { inquiryDataStream } from './inquiry';
import { call } from '../../../../ui-utils/client';
import { getUserPreference } from '../../../../utils';
import { CustomSounds } from '../../../../custom-sounds/client/lib/CustomSounds';

const departments = new Set();

const newInquirySound = () => {
const userId = Meteor.userId();
const audioVolume = getUserPreference(userId, 'notificationsSoundVolume');
const newRoomNotification = getUserPreference(userId, 'newRoomNotification');
const audioNotificationValue = getUserPreference(userId, 'audioNotifications');

if (audioNotificationValue !== 'none') {
CustomSounds.play(newRoomNotification, {
volume: Number((audioVolume / 100).toPrecision(2)),
});
}
};

const events = {
added: (inquiry) => {
delete inquiry.type;
departments.has(inquiry.department) && LivechatInquiry.insert({ ...inquiry, alert: true, _updatedAt: new Date(inquiry._updatedAt) });
newInquirySound();
},
changed: (inquiry) => {
if (inquiry.status !== 'queued' || (inquiry.department && !departments.has(inquiry.department))) {
Expand Down