|
@@ -0,0 +1,59 @@
|
|
|
+import { Component } from '@angular/core';
|
|
|
+import { IonicPage, NavController, NavParams, InfiniteScroll } from 'ionic-angular';
|
|
|
+import { TwitterApiProvider } from '../../providers/twitter-api/twitter-api';
|
|
|
+
|
|
|
+/**
|
|
|
+ * Generated class for the ProfilePage page.
|
|
|
+ *
|
|
|
+ * See https://ionicframework.com/docs/components/#navigation for more info on
|
|
|
+ * Ionic pages and navigation.
|
|
|
+ */
|
|
|
+
|
|
|
+@IonicPage()
|
|
|
+@Component({
|
|
|
+ selector: 'page-profile',
|
|
|
+ templateUrl: 'profile.html',
|
|
|
+})
|
|
|
+export class ProfilePage {
|
|
|
+
|
|
|
+ userId: string;
|
|
|
+ user: any = [];
|
|
|
+ tweets: any[];
|
|
|
+
|
|
|
+ constructor(
|
|
|
+ public navCtrl: NavController,
|
|
|
+ public navParams: NavParams,
|
|
|
+ private twitter: TwitterApiProvider
|
|
|
+ ) {
|
|
|
+ }
|
|
|
+
|
|
|
+ ionViewDidLoad() {
|
|
|
+ this.userId = this.navParams.get('userId');
|
|
|
+
|
|
|
+ this.twitter.fetchUser(this.userId)
|
|
|
+ .then(res => {
|
|
|
+ this.user = res;
|
|
|
+ });
|
|
|
+
|
|
|
+ this.twitter.fetchUserTimeline(this.userId)
|
|
|
+ .then(res => {
|
|
|
+ this.tweets = res;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ doRefresh(refresher) {
|
|
|
+ this.twitter.fetchUserTimeline(this.userId)
|
|
|
+ .then(res => {
|
|
|
+ this.tweets = res.data;
|
|
|
+ refresher.complete();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ loadMore(infiniteScroll: InfiniteScroll) {
|
|
|
+ this.twitter.fetchUserTimelineSince(this.userId, this.tweets[this.tweets.length - 1].id)
|
|
|
+ .then(res => {
|
|
|
+ this.tweets = this.tweets.concat(res.data);
|
|
|
+ infiniteScroll.complete();
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|