Procházet zdrojové kódy

Show loading indicator while loading

Carsten Porth před 6 roky
rodič
revize
d54d4cef46
1 změnil soubory, kde provedl 10 přidání a 3 odebrání
  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) {