File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { Component } from "@angular/core" ;
2+ import { Alert , AlertController , NavController } from "ionic-angular" ;
3+ import { PhoneService } from "../../services/phone" ;
4+ import { ProfilePage } from "../profile/profile" ;
5+
6+ @Component ( {
7+ selector : 'facebook' ,
8+ templateUrl : 'facebook.html'
9+ } )
10+ export class FacebookPage {
11+
12+ constructor ( private alertCtrl : AlertController ,
13+ private phoneService : PhoneService ,
14+ private navCtrl : NavController ) {
15+ }
16+
17+ cancel ( ) : void {
18+ const alert : Alert = this . alertCtrl . create ( {
19+ title : 'Confirm' ,
20+ message : `Would you like to proceed without linking your account with Facebook?` ,
21+ buttons : [
22+ {
23+ text : 'Cancel' ,
24+ role : 'cancel'
25+ } ,
26+ {
27+ text : 'Yes' ,
28+ handler : ( ) => {
29+ this . dontLink ( alert ) ;
30+ return false ;
31+ }
32+ }
33+ ]
34+ } ) ;
35+
36+ alert . present ( ) ;
37+ }
38+
39+ linkFacebook ( ) : void {
40+ this . phoneService . linkFacebook ( )
41+ . then ( ( ) => {
42+ this . navCtrl . setRoot ( ProfilePage , { } , {
43+ animate : true
44+ } ) ;
45+ } )
46+ . catch ( ( e ) => {
47+ this . handleError ( e ) ;
48+ } ) ;
49+ }
50+
51+ dontLink ( alert : Alert ) : void {
52+ alert . dismiss ( )
53+ . then ( ( ) => {
54+ this . navCtrl . setRoot ( ProfilePage , { } , {
55+ animate : true
56+ } ) ;
57+ } )
58+ . catch ( ( e ) => {
59+ this . handleError ( e ) ;
60+ } ) ;
61+ }
62+
63+ handleError ( e : Error ) : void {
64+ console . error ( e ) ;
65+
66+ const alert = this . alertCtrl . create ( {
67+ title : 'Oops!' ,
68+ message : e . message ,
69+ buttons : [ 'OK' ]
70+ } ) ;
71+
72+ alert . present ( ) ;
73+ }
74+ }
You can’t perform that action at this time.
0 commit comments