Skip to content

Commit

Permalink
Step 2.10: Use TypeScript models
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and darkbasic committed Oct 16, 2017
1 parent 79e50d5 commit 36f4674
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/pages/chats/chats.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import * as moment from 'moment';
import { Chat, MessageType } from '../../models';

@Component({
templateUrl: 'chats.html'
})
export class ChatsPage {
chats: Observable<any[]>;
chats: Observable<Chat[]>;

constructor() {
this.chats = this.findChats();
}

private findChats(): Observable<any[]> {
private findChats(): Observable<Chat[]> {
return Observable.of([
{
_id: '0',
title: 'Ethan Gonzalez',
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg',
lastMessage: {
content: 'You on your way?',
createdAt: moment().subtract(1, 'hours').toDate()
createdAt: moment().subtract(1, 'hours').toDate(),
type: MessageType.TEXT
}
},
{
Expand All @@ -29,7 +31,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg',
lastMessage: {
content: 'Hey, it\'s me',
createdAt: moment().subtract(2, 'hours').toDate()
createdAt: moment().subtract(2, 'hours').toDate(),
type: MessageType.TEXT
}
},
{
Expand All @@ -38,7 +41,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg',
lastMessage: {
content: 'I should buy a boat',
createdAt: moment().subtract(1, 'days').toDate()
createdAt: moment().subtract(1, 'days').toDate(),
type: MessageType.TEXT
}
},
{
Expand All @@ -47,7 +51,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg',
lastMessage: {
content: 'Look at my mukluks!',
createdAt: moment().subtract(4, 'days').toDate()
createdAt: moment().subtract(4, 'days').toDate(),
type: MessageType.TEXT
}
},
{
Expand All @@ -56,7 +61,8 @@ export class ChatsPage {
picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg',
lastMessage: {
content: 'This is wicked good ice cream.',
createdAt: moment().subtract(2, 'weeks').toDate()
createdAt: moment().subtract(2, 'weeks').toDate(),
type: MessageType.TEXT
}
}
]);
Expand Down

0 comments on commit 36f4674

Please sign in to comment.