@@ -14,9 +14,9 @@ import { ApiService } from '../common/services/apis.service';
1414export class ConversationsComponent implements OnInit , OnDestroy {
1515
1616 constructor ( public apiService : ApiService ,
17- public notificationsService : NotificationsService ,
18- public sharedDataService : SharedDataService ,
19- public _router : Router ) { }
17+ public notificationsService : NotificationsService ,
18+ public sharedDataService : SharedDataService ,
19+ public _router : Router ) { }
2020
2121 // tslint:disable-next-line: max-line-length
2222 conversationsDisplayedColumns : string [ ] = [ 'conversation_id' , 'conversation_timestamp' , 'icon' ] ;
@@ -38,15 +38,18 @@ export class ConversationsComponent implements OnInit, OnDestroy {
3838 getConversations ( ) {
3939 this . apiService . requestConversations ( ) . subscribe ( conversations => {
4040 if ( conversations ) {
41- this . conversations_json = conversations . slice ( ) . reverse ( ) ;
41+ this . conversations_json = conversations . sort ( function ( a , b ) {
42+ var x = a [ 'latest_event_time' ] ; var y = b [ 'latest_event_time' ] ;
43+ return ( ( x > y ) ? - 1 : ( ( x < y ) ? 1 : 0 ) ) ;
44+ } ) ;
4245 this . conversations_json_backup = JSON . parse ( JSON . stringify ( this . conversations_json ) ) ;
4346 this . conversationsDataSource = new MatTableDataSource ( this . conversations_json ) ;
4447 this . conversationsDataSource . paginator = this . paginator ;
4548 this . applyConversationsFilter ( this . filterConversationText ) ;
4649 }
4750 } ,
48- err => console . error ( 'Observer got an error: ' + err ) ,
49- ( ) => console . log ( 'Observer got a complete notification' ) ) ;
51+ err => console . error ( 'Observer got an error: ' + err ) ,
52+ ( ) => console . log ( 'Observer got a complete notification' ) ) ;
5053 }
5154
5255 applyConversationsFilter ( filterValue : string ) {
@@ -55,11 +58,11 @@ export class ConversationsComponent implements OnInit, OnDestroy {
5558 const converted_ts = this . convertTimestamp ( value [ 'latest_event_time' ] ) ;
5659 // tslint:disable-next-line: max-line-length
5760 if ( value [ 'sender_id' ] . includes ( filterValue . trim ( ) ) ||
58- value [ 'sender_id' ] . toLowerCase ( ) . includes ( filterValue . trim ( ) ) ||
59- value [ 'sender_id' ] . toUpperCase ( ) . includes ( filterValue . trim ( ) ) ||
60- converted_ts . includes ( filterValue . trim ( ) ) ||
61- converted_ts . includes ( filterValue . trim ( ) ) ||
62- converted_ts . includes ( filterValue . trim ( ) ) ) {
61+ value [ 'sender_id' ] . toLowerCase ( ) . includes ( filterValue . trim ( ) ) ||
62+ value [ 'sender_id' ] . toUpperCase ( ) . includes ( filterValue . trim ( ) ) ||
63+ converted_ts . includes ( filterValue . trim ( ) ) ||
64+ converted_ts . includes ( filterValue . trim ( ) ) ||
65+ converted_ts . includes ( filterValue . trim ( ) ) ) {
6366 return value ;
6467 }
6568 } ) ;
0 commit comments