Skip to content

Commit

Permalink
Step 5.20: Add profile component
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 26, 2017
1 parent d0b8c56 commit f1cff0f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/pages/profile/profile.ts
@@ -0,0 +1,48 @@
import { Component, OnInit } from '@angular/core';
import { NavController, AlertController } from 'ionic-angular';
import { MeteorObservable } from 'meteor-rxjs';
import { Profile } from 'api/models/whatsapp-models';
import { TabsPage } from "../tabs/tabs";

@Component({
selector: 'profile',
templateUrl: 'profile.html'
})
export class ProfileComponent implements OnInit {
profile: Profile;

constructor(
public navCtrl: NavController,
public alertCtrl: AlertController
) {}

ngOnInit(): void {
this.profile = Meteor.user().profile || {
name: '',
picture: '/ionicons/dist/svg/ios-contact.svg'
};
}

done(): void {
MeteorObservable.call('updateProfile', this.profile).subscribe({
next: () => {
this.navCtrl.push(TabsPage);
},
error: (e: Error) => {
this.handleError(e);
}
});
}

private handleError(e: Error): void {
console.error(e);

const alert = this.alertCtrl.create({
title: 'Oops!',
message: e.message,
buttons: ['OK']
});

alert.present();
}
}

0 comments on commit f1cff0f

Please sign in to comment.