File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Component , OnInit } from '@angular/core' ;
2+ import { Profile } from 'api/models' ;
3+ import { AlertController , NavController } from 'ionic-angular' ;
4+ import { MeteorObservable } from 'meteor-rxjs' ;
5+ import { ChatsPage } from '../chats/chats' ;
6+
7+ @Component ( {
8+ selector : 'profile' ,
9+ templateUrl : 'profile.html'
10+ } )
11+ export class ProfilePage implements OnInit {
12+ picture : string ;
13+ profile : Profile ;
14+
15+ constructor (
16+ private alertCtrl : AlertController ,
17+ private navCtrl : NavController
18+ ) { }
19+
20+ ngOnInit ( ) : void {
21+ this . profile = Meteor . user ( ) . profile || {
22+ name : ''
23+ } ;
24+ }
25+
26+ updateProfile ( ) : void {
27+ MeteorObservable . call ( 'updateProfile' , this . profile ) . subscribe ( {
28+ next : ( ) => {
29+ this . navCtrl . push ( ChatsPage ) ;
30+ } ,
31+ error : ( e : Error ) => {
32+ this . handleError ( e ) ;
33+ }
34+ } ) ;
35+ }
36+
37+ handleError ( e : Error ) : void {
38+ console . error ( e ) ;
39+
40+ const alert = this . alertCtrl . create ( {
41+ title : 'Oops!' ,
42+ message : e . message ,
43+ buttons : [ 'OK' ]
44+ } ) ;
45+
46+ alert . present ( ) ;
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments