@@ -40,9 +40,9 @@ class MessagesPage extends Component {
4040 }
4141 return recipients . map ( ( recipient ) => {
4242 const phoneNumber = recipient . phoneNumber || recipient . extensionNumber ;
43- if ( recipient . matchedNames ) {
44- const matcherName = recipient . matchedNames . map ( matcher => matcher . name ) . join ( '&' ) ;
45- if ( matcherName . length > 0 ) {
43+ if ( phoneNumber && this . props . matcherContactName ) {
44+ const matcherName = this . props . matcherContactName ( phoneNumber ) ;
45+ if ( matcherName ) {
4646 return matcherName ;
4747 }
4848 return this . props . formatPhone ( phoneNumber ) ;
@@ -63,9 +63,9 @@ class MessagesPage extends Component {
6363 if ( searchNumber && searchNumber . length > 0 && phoneNumber . indexOf ( searchNumber ) >= 0 ) {
6464 return true ;
6565 }
66- if ( recipient . matchedNames ) {
67- const matcherName = recipient . matchedNames . map ( matcher => matcher . name ) . join ( '&' ) ;
68- if ( matcherName . length > 0 ) {
66+ if ( this . props . matcherContactName ) {
67+ const matcherName = this . props . matcherContactName ( phoneNumber ) ;
68+ if ( matcherName ) {
6969 recipientName = matcherName ;
7070 } else {
7171 recipientName = phoneNumber ;
@@ -175,12 +175,17 @@ MessagesPage.propTypes = {
175175 getRecipientsList : PropTypes . func . isRequired ,
176176 searchMessagesText : PropTypes . func . isRequired ,
177177 updateSearchResults : PropTypes . func . isRequired ,
178+ matcherContactName : PropTypes . func ,
179+ } ;
180+
181+ MessagesPage . defaultProps = {
182+ matcherContactName : null ,
178183} ;
179184
180185function mapStateToProps ( state , props ) {
181186 return ( {
182187 currentLocale : props . locale . currentLocale ,
183- messages : props . messages . normalizedMessages ,
188+ messages : props . messages . messages ,
184189 allMessages : props . messageStore . conversations ,
185190 showSpinner : (
186191 ! props . messages . ready ||
@@ -195,6 +200,16 @@ function mapStateToProps(state, props) {
195200}
196201
197202function mapDispatchToProps ( dispatch , props ) {
203+ let matcherContactName = null ;
204+ if ( props . contactMatcher && props . contactMatcher . ready ) {
205+ matcherContactName = ( phoneNumber ) => {
206+ const matcherNames = props . contactMatcher . dataMapping [ phoneNumber ] ;
207+ if ( matcherNames && matcherNames . length > 0 ) {
208+ return matcherNames . map ( matcher => matcher . name ) . join ( '&' ) ;
209+ }
210+ return null ;
211+ } ;
212+ }
198213 return {
199214 loadNextPageMessages : props . messages . loadNextPageMessages ,
200215 updateSearchingString : props . messages . updateSearchingString ,
@@ -214,6 +229,7 @@ function mapDispatchToProps(dispatch, props) {
214229 } ) ,
215230 searchMessagesText : searchText =>
216231 props . messageStore . searchMessagesText ( searchText ) ,
232+ matcherContactName,
217233 } ;
218234}
219235
0 commit comments