|
1 | 1 | import { Component } from '@angular/core'; |
| 2 | +import { Observable } from 'rxjs'; |
| 3 | +import * as moment from 'moment'; |
2 | 4 |
|
3 | 5 | @Component({ |
4 | 6 | templateUrl: 'chats.html' |
5 | 7 | }) |
6 | 8 | export class ChatsPage { |
| 9 | + chats: Observable<any[]>; |
| 10 | + |
7 | 11 | constructor() { |
| 12 | + this.chats = this.findChats(); |
| 13 | + } |
8 | 14 |
|
| 15 | + private findChats(): Observable<any[]> { |
| 16 | + return Observable.of([ |
| 17 | + { |
| 18 | + _id: '0', |
| 19 | + title: 'Ethan Gonzalez', |
| 20 | + picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg', |
| 21 | + lastMessage: { |
| 22 | + content: 'You on your way?', |
| 23 | + createdAt: moment().subtract(1, 'hours').toDate() |
| 24 | + } |
| 25 | + }, |
| 26 | + { |
| 27 | + _id: '1', |
| 28 | + title: 'Bryan Wallace', |
| 29 | + picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg', |
| 30 | + lastMessage: { |
| 31 | + content: 'Hey, it\'s me', |
| 32 | + createdAt: moment().subtract(2, 'hours').toDate() |
| 33 | + } |
| 34 | + }, |
| 35 | + { |
| 36 | + _id: '2', |
| 37 | + title: 'Avery Stewart', |
| 38 | + picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg', |
| 39 | + lastMessage: { |
| 40 | + content: 'I should buy a boat', |
| 41 | + createdAt: moment().subtract(1, 'days').toDate() |
| 42 | + } |
| 43 | + }, |
| 44 | + { |
| 45 | + _id: '3', |
| 46 | + title: 'Katie Peterson', |
| 47 | + picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg', |
| 48 | + lastMessage: { |
| 49 | + content: 'Look at my mukluks!', |
| 50 | + createdAt: moment().subtract(4, 'days').toDate() |
| 51 | + } |
| 52 | + }, |
| 53 | + { |
| 54 | + _id: '4', |
| 55 | + title: 'Ray Edwards', |
| 56 | + picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg', |
| 57 | + lastMessage: { |
| 58 | + content: 'This is wicked good ice cream.', |
| 59 | + createdAt: moment().subtract(2, 'weeks').toDate() |
| 60 | + } |
| 61 | + } |
| 62 | + ]); |
9 | 63 | } |
10 | 64 | } |
0 commit comments