fix: don't show published poll notification if chat push alert is active

This commit is contained in:
Joao Victor 2022-11-07 14:47:20 -03:00
parent 94c91d8f79
commit 0c4f8b7c44
3 changed files with 27 additions and 4 deletions

View File

@ -46,6 +46,7 @@ import LayoutService from '/imports/ui/components/layout/service';
import { registerTitleView } from '/imports/utils/dom-utils';
import GlobalStyles from '/imports/ui/stylesheets/styled-components/globalStyles';
import MediaService from '/imports/ui/components/media/service';
import { toast } from 'react-toastify';
const MOBILE_MEDIA = 'only screen and (max-width: 40em)';
const APP_CONFIG = Meteor.settings.public.app;
@ -128,6 +129,8 @@ const defaultProps = {
const isLayeredView = window.matchMedia(`(max-width: ${SMALL_VIEWPORT_BREAKPOINT}px)`);
let publishedPollToast = null;
class App extends Component {
static renderWebcamsContainer() {
return <NewWebcamContainer />;
@ -252,6 +255,7 @@ class App extends Component {
pushLayoutToEveryone, // is layout pushed
layoutContextDispatch,
mountRandomUserModal,
ignorePollNotifications,
} = this.props;
if (meetingLayout !== prevProps.meetingLayout) {
@ -313,10 +317,11 @@ class App extends Component {
intl.formatMessage(intlMessages.meetingMuteOff), 'info', 'unmute',
);
}
if (!prevProps.hasPublishedPoll && hasPublishedPoll) {
notify(
if (!prevProps.hasPublishedPoll && hasPublishedPoll && !ignorePollNotifications) {
const id = notify(
intl.formatMessage(intlMessages.pollPublishedLabel), 'info', 'polling',
);
if (id) publishedPollToast = id;
}
if (prevProps.currentUserRole === VIEWER && currentUserRole === MODERATOR) {
notify(
@ -330,6 +335,8 @@ class App extends Component {
}
if (deviceType === null || prevProps.deviceType !== deviceType) this.throttledDeviceType();
if (ignorePollNotifications && publishedPollToast) toast.dismiss(publishedPollToast);
}
componentWillUnmount() {

View File

@ -250,6 +250,7 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls })
autoSwapLayout: getFromUserSettings('bbb_auto_swap_layout', LAYOUT_CONFIG.autoSwapLayout),
hideActionsBar: getFromUserSettings('bbb_hide_actions_bar', false),
isModalOpen: !!getModal(),
ignorePollNotifications: Session.get('ignorePollNotifications'),
};
})(AppContainer)));

View File

@ -10,6 +10,7 @@ import { stripTags, unescapeHtml } from '/imports/utils/string-utils';
import Service from '../service';
import Styled from './styles';
import { usePreviousValue } from '/imports/ui/components/utils/hooks';
import { Session } from 'meteor/session';
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_CLEAR = CHAT_CONFIG.chat_clear;
@ -193,9 +194,11 @@ const ChatAlert = (props) => {
const mappedMessage = Service.mapGroupMessage(timeWindow);
let content = null;
let isPollResult = false;
if (mappedMessage) {
if (mappedMessage.id.includes(POLL_RESULT_KEY)) {
content = createPollMessage();
isPollResult = true;
} else {
content = createMessage(mappedMessage.sender.name, mappedMessage.content.slice(-5));
}
@ -218,10 +221,22 @@ const ChatAlert = (props) => {
: <span>{intl.formatMessage(intlMessages.appToastChatPrivate)}</span>
}
onOpen={
() => setUnreadMessages(newUnreadMessages)
() => {
if (isPollResult) {
Session.set('ignorePollNotifications', true);
}
setUnreadMessages(newUnreadMessages);
}
}
onClose={
() => setUnreadMessages(newUnreadMessages)
() => {
if (isPollResult) {
Session.set('ignorePollNotifications', false);
}
setUnreadMessages(newUnreadMessages);
}
}
alertDuration={timeWindow.durationDiff}
layoutContextDispatch={layoutContextDispatch}