You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.1 KiB
75 lines
2.1 KiB
import React, { Component } from 'react'; |
|
import {Link} from 'react-router-dom'; |
|
import { chat } from '../../Redux/actions'; |
|
import { connect } from 'react-redux'; |
|
import ChatIcon from '@material-ui/icons/Chat'; |
|
import Chat from './Chat/index'; |
|
import Navbar from '../Home/Navbar/index'; |
|
import Search from './Search/index'; |
|
import Chatroom from '../ChatRoom/index'; |
|
|
|
import './index.scss'; |
|
import { DesktopWindowsRounded } from '@material-ui/icons'; |
|
|
|
class ChatList extends Component { |
|
state = { |
|
selectedUser: null, |
|
} |
|
|
|
|
|
componentDidMount() { |
|
this.props.list(); |
|
} |
|
render() { |
|
return ( |
|
<> |
|
{ |
|
window.innerWidth < 1000 ? |
|
<div className="chat-list d-flex flex-column"> |
|
<Navbar /> |
|
{this.props.chat_list.map((item, i) => ( |
|
<Chat key={i} data={item} /> |
|
))} |
|
<Link to="/characters" className="chat-list__float d-flex"> |
|
<ChatIcon fontSize="small" /> |
|
</Link> |
|
</div> : null |
|
} |
|
{ |
|
window.innerWidth > 1000 ? |
|
<div className="desktop-chat d-flex"> |
|
<div className="desktop-chat__banner"> |
|
|
|
</div> |
|
<div className="desktop-chat__list d-flex flex-column"> |
|
<Search /> |
|
{this.props.chat_list.map((item, i) => ( |
|
<Chat selectedUser={this.state.selectedUser} key={i} data={item} parent={this} /> |
|
))} |
|
<Link to="/characters" className="desktop-chat__list--float d-flex"> |
|
<ChatIcon fontSize="small" /> |
|
</Link> |
|
</div> |
|
{ |
|
this.state.selectedUser ? |
|
<Chatroom id={this.state.selectedUser} /> : |
|
<div className="desktop-chat__before d-flex"> |
|
<h1>برای شروع روی یک چت کلیک کن</h1> |
|
</div> |
|
} |
|
|
|
</div> : null |
|
} |
|
</> |
|
|
|
); |
|
} |
|
} |
|
|
|
export default connect( |
|
(state) => ({ |
|
chat_list: state.chat.list || [], |
|
}), |
|
{ list : chat.list } |
|
)(ChatList); |
|
|
|
|