Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9aba64
commit 5a4cc57
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Profile } from 'api/models'; | ||
import { AlertController, NavController } from 'ionic-angular'; | ||
import { MeteorObservable } from 'meteor-rxjs'; | ||
import { ChatsPage } from '../chats/chats'; | ||
|
||
@Component({ | ||
selector: 'profile', | ||
templateUrl: 'profile.html' | ||
}) | ||
export class ProfilePage implements OnInit { | ||
picture: string; | ||
profile: Profile; | ||
|
||
constructor( | ||
private alertCtrl: AlertController, | ||
private navCtrl: NavController | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.profile = Meteor.user().profile || { | ||
name: '' | ||
}; | ||
} | ||
|
||
updateProfile(): void { | ||
MeteorObservable.call('updateProfile', this.profile).subscribe({ | ||
next: () => { | ||
this.navCtrl.push(ChatsPage); | ||
}, | ||
error: (e: Error) => { | ||
this.handleError(e); | ||
} | ||
}); | ||
} | ||
|
||
handleError(e: Error): void { | ||
console.error(e); | ||
|
||
const alert = this.alertCtrl.create({ | ||
title: 'Oops!', | ||
message: e.message, | ||
buttons: ['OK'] | ||
}); | ||
|
||
alert.present(); | ||
} | ||
} |