@@ -29,6 +29,7 @@ import { createStructuredSelector } from 'reselect';
29
29
import {
30
30
selectPersonAction ,
31
31
sendMessage ,
32
+ unmatch ,
32
33
fetchMatchData ,
33
34
fetchMatchDataLocally ,
34
35
dumpAllInit ,
@@ -63,35 +64,39 @@ export class Messages extends React.Component { // eslint-disable-line react/pre
63
64
}
64
65
65
66
mapMatches ( ) {
66
- return this . props . selectMatches && this . props . selectMatches . map ( ( each ) => {
67
- return ( < MessengerCard
67
+ return this . props . selectMatches && this . props . selectMatches . map ( ( each ) =>
68
+ < MessengerCard
68
69
onClick = { this . props . selectPerson }
69
70
key = { each . _id }
70
71
data = { each }
71
72
isReply = { each . messages . length !== 0 && each . messages . slice ( - 1 ) [ 0 ] . from === this . props . currentUserId }
72
73
isNew = { each . person && each . person . _id && this . props . newMatches . indexOf ( each . person . _id ) !== - 1 }
73
- /> ) ;
74
- } ) ;
74
+ />
75
+ ) ;
75
76
}
76
77
77
78
mapMessages ( ) {
78
- return this . props . matchMessages . map ( ( each ) => {
79
- return ( < MessageBubble
79
+ return this . props . matchMessages . map ( ( each ) =>
80
+ < MessageBubble
80
81
key = { each . payload . _id }
81
82
from = { each . from }
82
83
date = { each . payload . sent_date }
83
84
>
84
85
{ each . payload . message }
85
- </ MessageBubble > ) ;
86
- } )
86
+ </ MessageBubble >
87
+ )
87
88
. concat ( this . props . selectOptimistic . map ( ( each ) => {
88
- if ( each . id === this . props . currentPerson . id ) {
89
- return ( < MessageBubble
90
- key = { each . message }
91
- from = "you" >
89
+ if ( each . id !== this . props . currentPerson . id ) {
90
+ return null ;
91
+ }
92
+
93
+ return (
94
+ < MessageBubble
95
+ key = { each . message }
96
+ from = "you"
97
+ >
92
98
{ each . message }
93
99
</ MessageBubble > ) ;
94
- }
95
100
} ) ) ;
96
101
}
97
102
@@ -102,7 +107,8 @@ export class Messages extends React.Component { // eslint-disable-line react/pre
102
107
if ( this . props . selectMatches ) {
103
108
return < FormattedMessage { ...messages . whenLoadedData } /> ;
104
109
}
105
- return < FormattedMessage { ...messages . whenNoDataisFound } /> ;
110
+
111
+ return < FormattedMessage { ...messages . whenNoDataisFound } /> ;
106
112
}
107
113
108
114
render ( ) {
@@ -154,6 +160,8 @@ export class Messages extends React.Component { // eslint-disable-line react/pre
154
160
< DetailView
155
161
data = { this . props . currentPerson . person }
156
162
imageData = { this . props . matchDetailImages }
163
+ unmatch = { this . props . onUnmatch }
164
+ matchId = { this . props . currentPerson && this . props . currentPerson . _id }
157
165
/> :
158
166
< Panel hasMatches targetGender = { this . props . targetGender } /> }
159
167
</ div >
@@ -169,6 +177,7 @@ function mapDispatchToProps(dispatch) {
169
177
return {
170
178
selectPerson : ( id ) => dispatch ( selectPersonAction ( id ) ) ,
171
179
onSendMessage : ( id , message ) => dispatch ( sendMessage ( id , message ) ) ,
180
+ onUnmatch : ( id ) => dispatch ( unmatch ( id ) ) ,
172
181
fetchHistory : ( ) => dispatch ( fetchMatchData ( ) ) ,
173
182
fetchHistoryLocally : ( ) => dispatch ( fetchMatchDataLocally ( ) ) ,
174
183
dumpAll : ( ) => dispatch ( dumpAllInit ( ) ) ,
@@ -199,6 +208,7 @@ Messages.propTypes = {
199
208
matchMessages : PropTypes . array ,
200
209
matchDetailImages : PropTypes . array ,
201
210
onSendMessage : PropTypes . func ,
211
+ onUnmatch : PropTypes . func ,
202
212
fetchHistory : PropTypes . func ,
203
213
selectOptimisticUI : PropTypes . func ,
204
214
selectOptimistic : PropTypes . array ,
0 commit comments