lint + cleanup
This commit is contained in:
parent
94436d2630
commit
3c41c6fd83
@ -1,4 +1,4 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { throttle } from 'lodash';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
@ -30,7 +30,7 @@ import NewWebcamContainer from '../webcam/container';
|
||||
import PresentationPodsContainer from '../presentation-pod/container';
|
||||
import { styles } from './styles';
|
||||
import {
|
||||
LAYOUT_TYPE, DEVICE_TYPE, ACTIONS, PANELS,
|
||||
LAYOUT_TYPE, DEVICE_TYPE, ACTIONS,
|
||||
} from '../layout/enums';
|
||||
import {
|
||||
isMobile, isTablet, isTabletPortrait, isTabletLandscape, isDesktop,
|
||||
@ -44,7 +44,6 @@ import SidebarNavigationContainer from '../sidebar-navigation/container';
|
||||
import SidebarContentContainer from '../sidebar-content/container';
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
import ConnectionStatusService from '/imports/ui/components/connection-status/service';
|
||||
import { NAVBAR_HEIGHT } from '/imports/ui/components/layout/layout-manager/component';
|
||||
|
||||
const MOBILE_MEDIA = 'only screen and (max-width: 40em)';
|
||||
const APP_CONFIG = Meteor.settings.public.app;
|
||||
@ -421,7 +420,7 @@ class App extends Component {
|
||||
sidebarNavigationIsOpen,
|
||||
sidebarContentIsOpen,
|
||||
audioAlertEnabled,
|
||||
pushAlertEnabled
|
||||
pushAlertEnabled,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@ -460,7 +459,13 @@ class App extends Component {
|
||||
<ModalContainer />
|
||||
<AudioContainer />
|
||||
<ToastContainer rtl />
|
||||
{(audioAlertEnabled || pushAlertEnabled) && <ChatAlertContainer audioAlertEnabled={audioAlertEnabled} pushAlertEnabled={pushAlertEnabled} /> }
|
||||
{(audioAlertEnabled || pushAlertEnabled)
|
||||
&& (
|
||||
<ChatAlertContainer
|
||||
audioAlertEnabled={audioAlertEnabled}
|
||||
pushAlertEnabled={pushAlertEnabled}
|
||||
/>
|
||||
)}
|
||||
<WaitingNotifierContainer />
|
||||
<LockNotifier />
|
||||
<StatusNotifier status="raiseHand" />
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Meteor } from "meteor/meteor";
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import _ from 'lodash';
|
||||
import AudioService from '/imports/ui/components/audio/service';
|
||||
@ -54,7 +54,7 @@ const ChatAlert = (props) => {
|
||||
unreadMessagesCountByChat,
|
||||
unreadMessagesByChat,
|
||||
intl,
|
||||
newLayoutContextDispatch
|
||||
newLayoutContextDispatch,
|
||||
} = props;
|
||||
|
||||
const [unreadMessagesCount, setUnreadMessagesCount] = useState(0);
|
||||
@ -68,9 +68,9 @@ const ChatAlert = (props) => {
|
||||
const unreadObject = JSON.parse(unreadMessagesCountByChat);
|
||||
|
||||
const unreadCount = document.hidden
|
||||
? unreadObject.reduce((a, b) => a + b.unreadCounter, 0)
|
||||
: unreadObject.filter((chat) => chat.chatId !== idChatOpen)
|
||||
.reduce((a, b) => a + b.unreadCounter, 0);
|
||||
? unreadObject.reduce((a, b) => a + b.unreadCounter, 0)
|
||||
: unreadObject.filter((chat) => chat.chatId !== idChatOpen)
|
||||
.reduce((a, b) => a + b.unreadCounter, 0);
|
||||
|
||||
if (audioAlertEnabled && unreadCount > unreadMessagesCount) {
|
||||
AudioService.playAlertSound(`${Meteor.settings.public.app.cdn
|
||||
@ -97,48 +97,43 @@ const ChatAlert = (props) => {
|
||||
let timewindowsToAlert = [];
|
||||
let filteredTimewindows = [];
|
||||
|
||||
alertsObject.forEach(chat => {
|
||||
alertsObject.forEach((chat) => {
|
||||
filteredTimewindows = filteredTimewindows.concat(
|
||||
chat.filter(timeWindow => {
|
||||
return timeWindow.timestamp > alertEnabledTimestamp
|
||||
})
|
||||
chat.filter((timeWindow) => timeWindow.timestamp > alertEnabledTimestamp),
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
filteredTimewindows.forEach(timeWindow => {
|
||||
filteredTimewindows.forEach((timeWindow) => {
|
||||
const durationDiff = ALERT_DURATION - (new Date().getTime() - timeWindow.timestamp);
|
||||
|
||||
if(timeWindow.lastTimestamp > timeWindow.timestamp){
|
||||
// é update de uma timewindow ja enviada
|
||||
// verifica se lasttimestamp é maior que ultimo alert exibido desse chat
|
||||
if(durationDiff > 0 && timeWindow.lastTimestamp > (lastAlertTimestampByChat[timeWindow.chatId] || 0)){
|
||||
//remover outros timewindows com mesmo key
|
||||
timewindowsToAlert = timewindowsToAlert.filter(item => item.chatId !== timeWindow.chatId);
|
||||
const newTimeWindow = {...timeWindow};
|
||||
if (timeWindow.lastTimestamp > timeWindow.timestamp) {
|
||||
if (durationDiff > 0
|
||||
&& timeWindow.lastTimestamp > (lastAlertTimestampByChat[timeWindow.chatId] || 0)) {
|
||||
timewindowsToAlert = timewindowsToAlert
|
||||
.filter((item) => item.chatId !== timeWindow.chatId);
|
||||
const newTimeWindow = { ...timeWindow };
|
||||
newTimeWindow.durationDiff = durationDiff;
|
||||
timewindowsToAlert.push(newTimeWindow);
|
||||
|
||||
const newLastAlertTimestampByChat = {...lastAlertTimestampByChat};
|
||||
if(timeWindow.timestamp > (lastAlertTimestampByChat[timeWindow.chatId] || 0)){
|
||||
const newLastAlertTimestampByChat = { ...lastAlertTimestampByChat };
|
||||
if (timeWindow.timestamp > (lastAlertTimestampByChat[timeWindow.chatId] || 0)) {
|
||||
newLastAlertTimestampByChat[timeWindow.chatId] = timeWindow.timestamp;
|
||||
setLastAlertTimestampByChat(newLastAlertTimestampByChat);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// new timeWindow, display if newer than last alert + alert interval
|
||||
if(timeWindow.timestamp > (lastAlertTimestampByChat[timeWindow.chatId] || 0) + ALERT_INTERVAL){
|
||||
timewindowsToAlert = timewindowsToAlert.filter(item => item.chatId !== timeWindow.chatId);
|
||||
timewindowsToAlert.push(timeWindow);
|
||||
|
||||
const newLastAlertTimestampByChat = {...lastAlertTimestampByChat};
|
||||
if(timeWindow.timestamp > (lastAlertTimestampByChat[timeWindow.chatId] || 0)){
|
||||
newLastAlertTimestampByChat[timeWindow.chatId] = timeWindow.timestamp;
|
||||
setLastAlertTimestampByChat(newLastAlertTimestampByChat);
|
||||
}
|
||||
} else if (timeWindow.timestamp
|
||||
> (lastAlertTimestampByChat[timeWindow.chatId] || 0) + ALERT_INTERVAL) {
|
||||
timewindowsToAlert = timewindowsToAlert
|
||||
.filter((item) => item.chatId !== timeWindow.chatId);
|
||||
timewindowsToAlert.push(timeWindow);
|
||||
|
||||
const newLastAlertTimestampByChat = { ...lastAlertTimestampByChat };
|
||||
if (timeWindow.timestamp > (lastAlertTimestampByChat[timeWindow.chatId] || 0)) {
|
||||
newLastAlertTimestampByChat[timeWindow.chatId] = timeWindow.timestamp;
|
||||
setLastAlertTimestampByChat(newLastAlertTimestampByChat);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
setUnreadMessages(timewindowsToAlert);
|
||||
}
|
||||
}, [unreadMessagesByChat]);
|
||||
@ -155,45 +150,49 @@ const ChatAlert = (props) => {
|
||||
});
|
||||
|
||||
return contentMessage;
|
||||
}
|
||||
|
||||
const createMessage = (name, message) => {
|
||||
return (
|
||||
<div className={styles.pushMessageContent}>
|
||||
<h3 className={styles.userNameMessage}>{name}</h3>
|
||||
<div className={styles.contentMessage}>
|
||||
{
|
||||
mapContentText(message)
|
||||
};
|
||||
|
||||
const createMessage = (name, message) => (
|
||||
<div className={styles.pushMessageContent}>
|
||||
<h3 className={styles.userNameMessage}>{name}</h3>
|
||||
<div className={styles.contentMessage}>
|
||||
{
|
||||
mapContentText(message)
|
||||
.reduce((acc, text) => [...acc, (<br key={_.uniqueId('br_')} />), text], [])
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</div>
|
||||
);
|
||||
|
||||
return pushAlertEnabled
|
||||
? unreadMessages.map(timeWindow => {
|
||||
? unreadMessages.map((timeWindow) => {
|
||||
const mappedMessage = Service.mapGroupMessage(timeWindow);
|
||||
const content = mappedMessage ? createMessage(mappedMessage.sender.name, mappedMessage.content.slice(-5)) : null;
|
||||
const content = mappedMessage
|
||||
? createMessage(mappedMessage.sender.name, mappedMessage.content.slice(-5))
|
||||
: null;
|
||||
|
||||
return content ? <ChatPushAlert
|
||||
key={mappedMessage.chatId}
|
||||
chatId={mappedMessage.chatId}
|
||||
content={content}
|
||||
title={
|
||||
(mappedMessage.chatId === 'MAIN-PUBLIC-GROUP-CHAT')
|
||||
? <span>{intl.formatMessage(intlMessages.appToastChatPublic)}</span>
|
||||
: <span>{intl.formatMessage(intlMessages.appToastChatPrivate)}</span>
|
||||
}
|
||||
onOpen={
|
||||
() => {
|
||||
const newUnreadMessages = unreadMessages.filter(message => message.key !== mappedMessage.key);
|
||||
setUnreadMessages(newUnreadMessages);
|
||||
}
|
||||
}
|
||||
alertDuration={timeWindow.durationDiff || ALERT_DURATION}
|
||||
newLayoutContextDispatch={newLayoutContextDispatch}
|
||||
/> : null;
|
||||
return content
|
||||
? (
|
||||
<ChatPushAlert
|
||||
key={mappedMessage.chatId}
|
||||
chatId={mappedMessage.chatId}
|
||||
content={content}
|
||||
title={
|
||||
(mappedMessage.chatId === 'MAIN-PUBLIC-GROUP-CHAT')
|
||||
? <span>{intl.formatMessage(intlMessages.appToastChatPublic)}</span>
|
||||
: <span>{intl.formatMessage(intlMessages.appToastChatPrivate)}</span>
|
||||
}
|
||||
onOpen={
|
||||
() => {
|
||||
const newUnreadMessages = unreadMessages
|
||||
.filter((message) => message.key !== mappedMessage.key);
|
||||
setUnreadMessages(newUnreadMessages);
|
||||
}
|
||||
}
|
||||
alertDuration={timeWindow.durationDiff || ALERT_DURATION}
|
||||
newLayoutContextDispatch={newLayoutContextDispatch}
|
||||
/>
|
||||
) : null;
|
||||
})
|
||||
: null;
|
||||
};
|
||||
|
@ -39,18 +39,18 @@ const ChatAlertContainer = (props) => {
|
||||
|
||||
// audio alerts
|
||||
const unreadMessagesCountByChat = audioAlertEnabled
|
||||
? JSON.stringify(activeChats.map(chat => {
|
||||
return {chatId: chat.chatId, unreadCounter: chat.unreadCounter};
|
||||
}))
|
||||
: null;
|
||||
? JSON.stringify(activeChats.map((chat) => ({
|
||||
chatId: chat.chatId, unreadCounter: chat.unreadCounter,
|
||||
})))
|
||||
: null;
|
||||
|
||||
// push alerts
|
||||
const unreadMessagesByChat = pushAlertEnabled
|
||||
? JSON.stringify(activeChats.filter((chat) => chat.unreadCounter > 0).map(chat => {
|
||||
const chatId = (chat.chatId === 'public') ? PUBLIC_CHAT_ID : chat.chatId;
|
||||
return UnreadMessages.getUnreadMessages(chatId, groupChatsMessages);
|
||||
}))
|
||||
: null;
|
||||
? JSON.stringify(activeChats.filter((chat) => chat.unreadCounter > 0).map((chat) => {
|
||||
const chatId = (chat.chatId === 'public') ? PUBLIC_CHAT_ID : chat.chatId;
|
||||
return UnreadMessages.getUnreadMessages(chatId, groupChatsMessages);
|
||||
}))
|
||||
: null;
|
||||
|
||||
return (
|
||||
<ChatAlert
|
||||
|
@ -28,9 +28,17 @@ export function notify(message, type = 'default', icon, options, content, small)
|
||||
};
|
||||
|
||||
if (!toast.isActive(lastToast.id) || !_.isEqual(lastToastProps, toastProps)) {
|
||||
if(toast.isActive(lastToast.id) && _.isEqual(lastToastProps.key, toastProps.key) && options?.autoClose > 0){
|
||||
toast.update(lastToast.id, { render: <Toast {...toastProps} />, autoClose: options.autoClose, ...toastProps });
|
||||
}else{
|
||||
if (toast.isActive(lastToast.id)
|
||||
&& _.isEqual(lastToastProps.key, toastProps.key) && options?.autoClose > 0) {
|
||||
toast.update(
|
||||
lastToast.id,
|
||||
{
|
||||
render: <Toast {...toastProps} />,
|
||||
autoClose: options.autoClose,
|
||||
...toastProps,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
const id = toast(<Toast {...toastProps} />, settings);
|
||||
|
||||
lastToast = { id, ...toastProps };
|
||||
|
Loading…
Reference in New Issue
Block a user