|
@@ -1,5 +1,5 @@
|
|
|
import { Component } from '@angular/core';
|
|
|
-import { NavController, MenuController } from 'ionic-angular';
|
|
|
+import { NavController, MenuController, InfiniteScroll } from 'ionic-angular';
|
|
|
import { TwitterApiProvider } from '../../providers/twitter-api/twitter-api';
|
|
|
|
|
|
@Component({
|
|
@@ -18,22 +18,31 @@ export class HomePage {
|
|
|
|
|
|
ionViewDidLoad() {
|
|
|
this.menuCtrl.enable(true, 'sideNav');
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ionViewDidEnter() {
|
|
|
this.twitter.fetchHomeFeed()
|
|
|
- .then(res => {
|
|
|
- console.log(res);
|
|
|
- this.data = res.data;
|
|
|
- });
|
|
|
+ .then(res => {
|
|
|
+ console.log(res);
|
|
|
+ this.data = res.data;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
doRefresh(refresher) {
|
|
|
this.twitter.fetchHomeFeed()
|
|
|
- .then(res => {
|
|
|
- this.data = res.data;
|
|
|
- refresher.complete();
|
|
|
- })
|
|
|
+ .then(res => {
|
|
|
+ this.data = res.data;
|
|
|
+ refresher.complete();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ loadMore(infiniteScroll: InfiniteScroll) {
|
|
|
+ console.log("loading more tweets now...");
|
|
|
+ this.twitter.fetchHomeFeedSince(this.data[this.data.length - 1].id)
|
|
|
+ .then(res => {
|
|
|
+ this.data = this.data.concat(res.data);
|
|
|
+ infiniteScroll.complete();
|
|
|
+ })
|
|
|
}
|
|
|
}
|