Skip to content

Commit 36f4674

Browse files
dotansimhadarkbasic
authored andcommitted
Step 2.10: Use TypeScript models
1 parent 79e50d5 commit 36f4674

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/pages/chats/chats.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import { Component } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import * as moment from 'moment';
4+
import { Chat, MessageType } from '../../models';
45

56
@Component({
67
templateUrl: 'chats.html'
78
})
89
export 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

Comments
 (0)