|
|
@ -9,231 +9,15 @@ import ReactAudioPlayer from 'react-audio-player'; |
|
|
|
import photo from '../../../assets/images/reza.png'; |
|
|
|
import photo from '../../../assets/images/reza.png'; |
|
|
|
import photo1 from '../../../assets/images/user2.png'; |
|
|
|
import photo1 from '../../../assets/images/user2.png'; |
|
|
|
import './Body.scss'; |
|
|
|
import './Body.scss'; |
|
|
|
export default class Body extends Component { |
|
|
|
import { list, send, sendKeys } from '../../../Redux/actions/message'; |
|
|
|
|
|
|
|
import { info, bio } from '../../../Redux/actions/chat'; |
|
|
|
|
|
|
|
import { connect } from 'react-redux'; |
|
|
|
|
|
|
|
class Body extends Component { |
|
|
|
constructor(props) { |
|
|
|
constructor(props) { |
|
|
|
super(props); |
|
|
|
super(props); |
|
|
|
this.state = { |
|
|
|
this.state = { |
|
|
|
data: { |
|
|
|
id: window.location.href.split('/').pop() * 1, |
|
|
|
id: '1', |
|
|
|
data: {}, |
|
|
|
users: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'u1', |
|
|
|
|
|
|
|
name: 'حسن', |
|
|
|
|
|
|
|
imageUri: photo, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'علی', |
|
|
|
|
|
|
|
imageUri: photo1, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
messages: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm1', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'چظوری!', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-10T12:48:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u1', |
|
|
|
|
|
|
|
name: 'علی', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm2', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'من خیلی خوبم', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:49:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'رضا', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm3', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'تو خودت چطوری؟', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:49:40.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'رضا', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm4', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'خوبی', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:50:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u1', |
|
|
|
|
|
|
|
name: 'علی', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm5', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'کجا رفتی؟', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:51:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u1', |
|
|
|
|
|
|
|
name: 'علی', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm6', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'نشد که بشه', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:49:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'رضا', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm7', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'من که به نظرم خوب نمیاد', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:53:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u1', |
|
|
|
|
|
|
|
name: 'علی', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm7', |
|
|
|
|
|
|
|
type: 'normal', |
|
|
|
|
|
|
|
text: 'یک تماس جدید', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:53:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u1', |
|
|
|
|
|
|
|
name: 'علی', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm10', |
|
|
|
|
|
|
|
type: '2d', |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
[{ id: 0, name: 'تکنولوژی' }], |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
{ id: 1, name: 'ورزشی' }, |
|
|
|
|
|
|
|
{ id: 2, name: 'علمی' }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
{ id: 3, name: 'مذهبی' }, |
|
|
|
|
|
|
|
{ id: 4, name: 'اجتماعی' }, |
|
|
|
|
|
|
|
{ id: 5, name: 'سیاسی' }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
text: 'به دنبال چی میگردی؟', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:53:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'رضا', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm11', |
|
|
|
|
|
|
|
type: 'draggable', |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
[{ id: 0, name: 'پرسپولیس', position: 1 }], |
|
|
|
|
|
|
|
[{ id: 1, name: 'سپاهان', position: 2 }], |
|
|
|
|
|
|
|
[{ id: 2, name: 'استقلال', position: 3 }], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
text: ' موقعیت تیمهای زیر را در پایان مسابقات جدول لیگ برتر را پیش بینی کنید!', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:53:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'رضا', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm12', |
|
|
|
|
|
|
|
type: 'slider', |
|
|
|
|
|
|
|
options: null, |
|
|
|
|
|
|
|
text: 'معدل شما درآزمون دکتری', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:53:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'رضا', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 'm13', |
|
|
|
|
|
|
|
type: 'radio', |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ id: 0, name: 'مادرید' }, |
|
|
|
|
|
|
|
{ id: 1, name: 'میلان' }, |
|
|
|
|
|
|
|
{ id: 2, name: 'رم' }, |
|
|
|
|
|
|
|
{ id: 3, name: 'ونیز' }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
text: 'پایتخت کشور ایتالیا؟', |
|
|
|
|
|
|
|
voice: null, |
|
|
|
|
|
|
|
image: null, |
|
|
|
|
|
|
|
video: null, |
|
|
|
|
|
|
|
music: null, |
|
|
|
|
|
|
|
document: null, |
|
|
|
|
|
|
|
createdAt: '2020-10-03T14:53:00.000Z', |
|
|
|
|
|
|
|
user: { |
|
|
|
|
|
|
|
id: 'u2', |
|
|
|
|
|
|
|
name: 'رضا', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
message: '', |
|
|
|
message: '', |
|
|
|
voice: null, |
|
|
|
voice: null, |
|
|
|
file: null, |
|
|
|
file: null, |
|
|
@ -548,8 +332,9 @@ export default class Body extends Component { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
componentDidMount() { |
|
|
|
let chatroom = document.getElementById('chatroom'); |
|
|
|
this.props.list({ chatId: this.state.id }); |
|
|
|
chatroom.scrollTop = chatroom.scrollHeight + 40; |
|
|
|
this.props.info({ id: this.state.id }); |
|
|
|
|
|
|
|
// this.componentDidUpdate();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate() { |
|
|
|
componentDidUpdate() { |
|
|
@ -562,8 +347,8 @@ export default class Body extends Component { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="chat-body d-flex flex-column"> |
|
|
|
<div className="chat-body d-flex flex-column"> |
|
|
|
<div className="chat-room__status d-flex flex-column" onClick={() => setPage('info')}> |
|
|
|
<div className="chat-room__status d-flex flex-column" onClick={() => setPage('info')}> |
|
|
|
<h1>محسن محمدی</h1> |
|
|
|
<h1>{this.props.info.title}</h1> |
|
|
|
<p>2 دقیقه پیش آنلاین بوده</p> |
|
|
|
<p>{this.props.info.subtitle}</p> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div |
|
|
|
<div |
|
|
|
className="chat-body__content d-flex flex-column" |
|
|
|
className="chat-body__content d-flex flex-column" |
|
|
@ -574,15 +359,15 @@ export default class Body extends Component { |
|
|
|
paddingBottom: this.state.footer === 'suggest' ? 110 : 70, |
|
|
|
paddingBottom: this.state.footer === 'suggest' ? 110 : 70, |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{this.state.data.messages.map((item, i) => |
|
|
|
{this.props.message_list.map((item, i) => |
|
|
|
this.state.image === null && this.state.music === null && this.state.video === null ? ( |
|
|
|
this.state.image === null && this.state.music === null && this.state.video === null ? ( |
|
|
|
<Message |
|
|
|
<Message |
|
|
|
|
|
|
|
isSelf={this.props.userId == item.userId} |
|
|
|
key={i} |
|
|
|
key={i} |
|
|
|
file={this.state.image} |
|
|
|
file={this.state.image} |
|
|
|
document={this.state.document} |
|
|
|
document={this.state.document} |
|
|
|
message={item} |
|
|
|
message={item} |
|
|
|
user1={this.state.data.users[0]} |
|
|
|
user={this.props.info.users[item.userId]} |
|
|
|
user2={this.state.data.users[1]} |
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
) : null |
|
|
|
) : null |
|
|
|
)} |
|
|
|
)} |
|
|
@ -604,7 +389,7 @@ export default class Body extends Component { |
|
|
|
{this.state.document !== null ? ( |
|
|
|
{this.state.document !== null ? ( |
|
|
|
<div className="chat-body__content--confirm d-flex"> |
|
|
|
<div className="chat-body__content--confirm d-flex"> |
|
|
|
<div className="chat-body__content--confirm___box d-flex flex-column"> |
|
|
|
<div className="chat-body__content--confirm___box d-flex flex-column"> |
|
|
|
<p>{`ارسال (${this.state.document.name}) به ${this.state.data.users[1].name}؟`}</p> |
|
|
|
<p>{`ارسال (${this.state.document.name}) به ${this.props.info.title}؟`}</p> |
|
|
|
<div className="chat-body__content--confirm___box---options d-flex"> |
|
|
|
<div className="chat-body__content--confirm___box---options d-flex"> |
|
|
|
<button style={{ color: '#00ff00' }} onClick={() => this.sendFile()}> |
|
|
|
<button style={{ color: '#00ff00' }} onClick={() => this.sendFile()}> |
|
|
|
ارسال |
|
|
|
ارسال |
|
|
@ -638,3 +423,11 @@ export default class Body extends Component { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export default connect( |
|
|
|
|
|
|
|
(state) => ({ |
|
|
|
|
|
|
|
info: state.chat.info, |
|
|
|
|
|
|
|
userId: state.user.id, |
|
|
|
|
|
|
|
message_list: state.message.list || [], |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
{ list, send, sendKeys, info, bio } |
|
|
|
|
|
|
|
)(Body); |
|
|
|