main
鲁誉程 2 months ago
parent 05fb19c521
commit af1fd4e98a

@ -1,13 +1,17 @@
import React from 'react'; import React, { useRef, useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import classnames from 'classnames';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import * as appPropTypes from './appPropTypes'; import * as appPropTypes from './appPropTypes';
import * as stateActions from '../redux/stateActions'; import * as stateActions from '../redux/stateActions';
import { Appear } from './transitions';
const Notifications = ({ notifications, onClick }) => { const Notifications = ({ notifications, onClick }) => {
console.log("notifications", notifications); const chatwarpRef = useRef(null);
useEffect(() => {
if (chatwarpRef.current) {
chatwarpRef.current.scrollTop = chatwarpRef.current.scrollHeight;
}
}, [notifications]);
return ( return (
<div data-component='Notifications' style={{ <div data-component='Notifications' style={{
@ -18,14 +22,12 @@ const Notifications = ({ notifications, onClick }) => {
}}> }}>
<div className='chatTitle'>聊天</div> <div className='chatTitle'>聊天</div>
<div className='chatwarp'> <div className='chatwarp' ref={chatwarpRef}>
{ {
notifications.map((notification) => { notifications.map((notification) => (
return (
<div key={notification.id} style={{ padding: '0 20px', fontSize: '14px' }}> <div key={notification.id} style={{ padding: '0 20px', fontSize: '14px' }}>
{ {
// notification.type === 'userMessage' ?
notification.type == 'userMessage' ?
<div style={{marginTop: 36}}> <div style={{marginTop: 36}}>
{ {
notification.isMe ? notification.isMe ?
@ -43,48 +45,25 @@ const Notifications = ({ notifications, onClick }) => {
</> </>
} }
</div> : </div> :
<div style={{width: '100%', margin: '20px 0', textAlign: 'center'}}> <div style={{width: '100%', margin: '30px 0', textAlign: 'center'}}>
{notification.text} {notification.text}
</div> </div>
} }
</div> </div>
))
//
// <Appear key={notification.id} duration={250}>
// <div
// className={classnames('notification', notification.type)}
// onClick={() => onClick(notification.id)}
// >
// <div className='icon' />
// <div className='body'>
// <If condition={notification.title}>
// <p className='title'>{notification.title}</p>
// </If>
// <p className='text'>{notification.text}</p>
// </div>
// </div>
// </Appear>
);
})
} }
</div> </div>
</div> </div>
); );
}; };
Notifications.propTypes = Notifications.propTypes = {
{
notifications: PropTypes.arrayOf(appPropTypes.Notification).isRequired, notifications: PropTypes.arrayOf(appPropTypes.Notification).isRequired,
onClick: PropTypes.func.isRequired onClick: PropTypes.func.isRequired
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { notifications } = state; const { notifications } = state;
return { notifications }; return { notifications };
}; };

@ -17,7 +17,7 @@ module.exports =
// Signaling settings (protoo WebSocket server and HTTP API server). // Signaling settings (protoo WebSocket server and HTTP API server).
https : https :
{ {
listenIp : '0.0.0.0', // 换成你的IP地址 listenIp : '192.168.0.167', // 换成你的IP地址
// NOTE: Don't change listenPort (client app assumes 4443). // NOTE: Don't change listenPort (client app assumes 4443).
listenPort : process.env.PROTOO_LISTEN_PORT || 4443, listenPort : process.env.PROTOO_LISTEN_PORT || 4443,
// NOTE: Set your own valid certificate files. // NOTE: Set your own valid certificate files.

Loading…
Cancel
Save