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);
|
||||
@ -97,23 +97,20 @@ 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);
|
||||
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);
|
||||
@ -124,10 +121,10 @@ const ChatAlert = (props) => {
|
||||
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);
|
||||
} else if (timeWindow.timestamp
|
||||
> (lastAlertTimestampByChat[timeWindow.chatId] || 0) + ALERT_INTERVAL) {
|
||||
timewindowsToAlert = timewindowsToAlert
|
||||
.filter((item) => item.chatId !== timeWindow.chatId);
|
||||
timewindowsToAlert.push(timeWindow);
|
||||
|
||||
const newLastAlertTimestampByChat = { ...lastAlertTimestampByChat };
|
||||
@ -135,10 +132,8 @@ const ChatAlert = (props) => {
|
||||
newLastAlertTimestampByChat[timeWindow.chatId] = timeWindow.timestamp;
|
||||
setLastAlertTimestampByChat(newLastAlertTimestampByChat);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
setUnreadMessages(timewindowsToAlert);
|
||||
}
|
||||
}, [unreadMessagesByChat]);
|
||||
@ -155,10 +150,9 @@ const ChatAlert = (props) => {
|
||||
});
|
||||
|
||||
return contentMessage;
|
||||
}
|
||||
};
|
||||
|
||||
const createMessage = (name, message) => {
|
||||
return (
|
||||
const createMessage = (name, message) => (
|
||||
<div className={styles.pushMessageContent}>
|
||||
<h3 className={styles.userNameMessage}>{name}</h3>
|
||||
<div className={styles.contentMessage}>
|
||||
@ -169,14 +163,17 @@ const ChatAlert = (props) => {
|
||||
</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
|
||||
return content
|
||||
? (
|
||||
<ChatPushAlert
|
||||
key={mappedMessage.chatId}
|
||||
chatId={mappedMessage.chatId}
|
||||
content={content}
|
||||
@ -187,13 +184,15 @@ const ChatAlert = (props) => {
|
||||
}
|
||||
onOpen={
|
||||
() => {
|
||||
const newUnreadMessages = unreadMessages.filter(message => message.key !== mappedMessage.key);
|
||||
const newUnreadMessages = unreadMessages
|
||||
.filter((message) => message.key !== mappedMessage.key);
|
||||
setUnreadMessages(newUnreadMessages);
|
||||
}
|
||||
}
|
||||
alertDuration={timeWindow.durationDiff || ALERT_DURATION}
|
||||
newLayoutContextDispatch={newLayoutContextDispatch}
|
||||
/> : null;
|
||||
/>
|
||||
) : null;
|
||||
})
|
||||
: null;
|
||||
};
|
||||
|
@ -39,14 +39,14 @@ const ChatAlertContainer = (props) => {
|
||||
|
||||
// audio alerts
|
||||
const unreadMessagesCountByChat = audioAlertEnabled
|
||||
? JSON.stringify(activeChats.map(chat => {
|
||||
return {chatId: chat.chatId, unreadCounter: chat.unreadCounter};
|
||||
}))
|
||||
? 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 => {
|
||||
? 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);
|
||||
}))
|
||||
|
@ -28,8 +28,16 @@ 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 });
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user