Parcourir la source

Show loading indicator while loading

Carsten Porth il y a 6 ans
Parent
commit
d54d4cef46
1 fichiers modifiés avec 10 ajouts et 3 suppressions
  1. 10 3
      app/src/pages/home/home.ts

+ 10 - 3
app/src/pages/home/home.ts

@@ -4,7 +4,8 @@ import {
   NavController,
   MenuController,
   InfiniteScroll,
-  Refresher
+  Refresher,
+  LoadingController
 } from "ionic-angular";
 import { Storage } from "@ionic/storage";
 import { WriteTweetPage } from "../write-tweet/write-tweet";
@@ -24,7 +25,8 @@ export class HomePage {
     public navCtrl: NavController,
     private menuCtrl: MenuController,
     private storage: Storage,
-    private feed: FeedProvider
+    private feed: FeedProvider,
+    private loadingCtrl: LoadingController
   ) {
     this.storage.get("userId").then(userId => (this.userId = userId));
   }
@@ -34,9 +36,14 @@ export class HomePage {
   }
 
   ionViewDidEnter() {
+    const loading = this.loadingCtrl.create();
+    loading.present();
+
     this.feed
       .loadHomeTimeline(this.userId)
-      .then(tweets => (this.tweets = tweets));
+      .then(tweets => (this.tweets = tweets))
+      .catch(err => console.error(err))
+      .then(() => loading.dismiss());
   }
 
   doRefresh(refresher: Refresher) {