Browse Source

displaying meaningfull alerts

rohit.gowda 4 years ago
parent
commit
e34ac9c3c0
2 changed files with 19 additions and 6 deletions
  1. 19 5
      app/src/pages/home/home.ts
  2. 0 1
      app/src/providers/auth/auth.ts

+ 19 - 5
app/src/pages/home/home.ts

@@ -4,6 +4,7 @@ import {
   NavController,
   MenuController,
   InfiniteScroll,
+  AlertController,
   Refresher,
   LoadingController
 } from "ionic-angular";
@@ -25,6 +26,7 @@ export class HomePage {
     public navCtrl: NavController,
     private menuCtrl: MenuController,
     private feed: FeedProvider,
+    private alertCtrl: AlertController,
     private loadingCtrl: LoadingController
   ) {}
 
@@ -33,13 +35,27 @@ export class HomePage {
   }
 
   ionViewDidEnter() {
+    const alertText = {
+      title: "Loading tweets failed",
+      subTitle: "Please try again.",
+      buttons: ["OK"]
+    };
+
     const loading = this.loadingCtrl.create();
     loading.present();
 
     this.feed
       .loadHomeTimeline()
-      .then(tweets => (this.tweets = tweets))
-      .catch(err => console.error(err))
+      .then(tweets => {
+          this.tweets=[];
+          Object.assign(this.tweets, tweets);
+          console.log("HOME tweets are: ", tweets);
+         })
+      .catch(err => {
+        console.error("err is:", err);
+        alertText.subTitle = err.message;
+        this.alertCtrl.create(alertText).present()
+      })
       .then(() => loading.dismiss());
   }
 
@@ -114,6 +130,4 @@ export class HomePage {
   }
 
 
-}
-
-
+}

+ 0 - 1
app/src/providers/auth/auth.ts

@@ -7,7 +7,6 @@ import { TwitterApiProvider } from "../twitter-api/twitter-api";
 @Injectable()
 export class AuthProvider {
   authProvider: any;
-
   constructor(
     public http: HttpClient,
     private storage: Storage,