11import { Component } from '@angular/core' ;
22import { Observable } from 'rxjs' ;
33import * as moment from 'moment' ;
4+ import { Chat , MessageType } from '../../models' ;
45
56@Component ( {
67 templateUrl : 'chats.html'
78} )
89export class ChatsPage {
9- chats : Observable < any [ ] > ;
10+ chats : Observable < Chat [ ] > ;
1011
1112 constructor ( ) {
1213 this . chats = this . findChats ( ) ;
1314 }
1415
15- private findChats ( ) : Observable < any [ ] > {
16+ private findChats ( ) : Observable < Chat [ ] > {
1617 return Observable . of ( [
1718 {
1819 _id : '0' ,
1920 title : 'Ethan Gonzalez' ,
2021 picture : 'https://randomuser.me/api/portraits/thumb/men/1.jpg' ,
2122 lastMessage : {
2223 content : 'You on your way?' ,
23- createdAt : moment ( ) . subtract ( 1 , 'hours' ) . toDate ( )
24+ createdAt : moment ( ) . subtract ( 1 , 'hours' ) . toDate ( ) ,
25+ type : MessageType . TEXT
2426 }
2527 } ,
2628 {
@@ -29,7 +31,8 @@ export class ChatsPage {
2931 picture : 'https://randomuser.me/api/portraits/thumb/lego/1.jpg' ,
3032 lastMessage : {
3133 content : 'Hey, it\'s me' ,
32- createdAt : moment ( ) . subtract ( 2 , 'hours' ) . toDate ( )
34+ createdAt : moment ( ) . subtract ( 2 , 'hours' ) . toDate ( ) ,
35+ type : MessageType . TEXT
3336 }
3437 } ,
3538 {
@@ -38,7 +41,8 @@ export class ChatsPage {
3841 picture : 'https://randomuser.me/api/portraits/thumb/women/1.jpg' ,
3942 lastMessage : {
4043 content : 'I should buy a boat' ,
41- createdAt : moment ( ) . subtract ( 1 , 'days' ) . toDate ( )
44+ createdAt : moment ( ) . subtract ( 1 , 'days' ) . toDate ( ) ,
45+ type : MessageType . TEXT
4246 }
4347 } ,
4448 {
@@ -47,7 +51,8 @@ export class ChatsPage {
4751 picture : 'https://randomuser.me/api/portraits/thumb/women/2.jpg' ,
4852 lastMessage : {
4953 content : 'Look at my mukluks!' ,
50- createdAt : moment ( ) . subtract ( 4 , 'days' ) . toDate ( )
54+ createdAt : moment ( ) . subtract ( 4 , 'days' ) . toDate ( ) ,
55+ type : MessageType . TEXT
5156 }
5257 } ,
5358 {
@@ -56,7 +61,8 @@ export class ChatsPage {
5661 picture : 'https://randomuser.me/api/portraits/thumb/men/2.jpg' ,
5762 lastMessage : {
5863 content : 'This is wicked good ice cream.' ,
59- createdAt : moment ( ) . subtract ( 2 , 'weeks' ) . toDate ( )
64+ createdAt : moment ( ) . subtract ( 2 , 'weeks' ) . toDate ( ) ,
65+ type : MessageType . TEXT
6066 }
6167 }
6268 ] ) ;
0 commit comments