2022-03-11 03:33:25 +08:00
|
|
|
import React from 'react';
|
2022-04-06 23:07:12 +08:00
|
|
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
2022-03-11 03:33:25 +08:00
|
|
|
import { Notifications as NotificationsCollection } from '/imports/api/meetings';
|
|
|
|
import { notify } from '/imports/ui/services/notification';
|
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2022-04-06 05:02:05 +08:00
|
|
|
import WaitingUsersAlertService from '/imports/ui/components/waiting-users/alert/service';
|
2022-04-06 21:21:49 +08:00
|
|
|
import UserService from '/imports/ui/components/user-list/service';
|
2024-02-26 22:26:55 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2024-02-27 20:38:08 +08:00
|
|
|
import useCurrentUser from '../../core/hooks/useCurrentUser';
|
2022-03-11 03:33:25 +08:00
|
|
|
|
2024-02-27 20:38:08 +08:00
|
|
|
const injectCurrentUser = (Component) => (props) => {
|
|
|
|
const { data: user } = useCurrentUser((u) => ({
|
|
|
|
presenter: u.presenter,
|
|
|
|
}));
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Component
|
|
|
|
{...props}
|
|
|
|
currentUser={user}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default injectIntl(injectCurrentUser(withTracker(({ intl, currentUser }) => {
|
2022-03-11 03:33:25 +08:00
|
|
|
NotificationsCollection.find({}).observe({
|
|
|
|
added: (obj) => {
|
2023-05-06 03:55:37 +08:00
|
|
|
NotificationsCollection.remove(obj);
|
|
|
|
|
2024-02-26 22:26:55 +08:00
|
|
|
if (
|
|
|
|
obj.messageId === 'app.whiteboard.annotations.poll'
|
|
|
|
&& Settings.application.chatPushAlerts
|
2024-02-27 20:38:08 +08:00
|
|
|
&& !currentUser?.presenter
|
2024-02-26 22:26:55 +08:00
|
|
|
) return null;
|
|
|
|
|
2022-04-06 05:02:05 +08:00
|
|
|
if (obj.messageId === 'app.userList.guest.pendingGuestAlert') {
|
2022-04-07 21:42:26 +08:00
|
|
|
return WaitingUsersAlertService.alert(obj, intl);
|
2022-04-06 05:02:05 +08:00
|
|
|
}
|
|
|
|
|
2022-04-06 21:21:49 +08:00
|
|
|
if (obj.messageId === 'app.notification.userJoinPushAlert') {
|
|
|
|
return UserService.UserJoinedMeetingAlert(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj.messageId === 'app.notification.userLeavePushAlert') {
|
|
|
|
return UserService.UserLeftMeetingAlert(obj);
|
|
|
|
}
|
|
|
|
|
2024-02-27 20:38:08 +08:00
|
|
|
return notify(
|
2022-03-11 03:33:25 +08:00
|
|
|
<FormattedMessage
|
|
|
|
id={obj.messageId}
|
|
|
|
values={obj.messageValues}
|
2022-03-30 22:01:12 +08:00
|
|
|
description={obj.messageDescription}
|
2022-03-11 03:33:25 +08:00
|
|
|
/>,
|
|
|
|
obj.notificationType,
|
|
|
|
obj.icon,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return {};
|
2024-02-27 20:38:08 +08:00
|
|
|
})(() => null)));
|