Browse Source

bugfix userid

Carsten Porth 6 years ago
parent
commit
99eb842883

+ 1 - 1
app/src/components/tweet-header/tweet-header.html

@@ -1,6 +1,6 @@
 <!-- Generated template for the TweetHeaderComponent component -->
 <div class="header-container">
-  <img src="{{ user.profile_image_url_https }}" alt="{{ user.name }}" class="avatar" (click)="showProfile(user.id)">
+  <img src="{{ user.profile_image_url_https }}" alt="{{ user.name }}" class="avatar" (click)="showProfile(user.id_str)">
   <div class="username" (click)="showProfile(user.id)">
     {{ user.name }}
     <span class="twitter-handle">@{{user.screen_name}}</span>

+ 4 - 8
app/src/pages/home/home.ts

@@ -34,14 +34,10 @@ export class HomePage {
   }
 
   async ionViewDidEnter() {
-    this.twitter
-      .fetchHomeFeed()
-      .then(
-        res =>
-          (this.data = this.data
-            .concat(res.data)
-            .sort((a, b) => this.sortByDateAsc(a, b)))
-      );
+    this.twitter.fetchHomeFeed().then(res => {
+      this.data = res.data.sort((a, b) => this.sortByDateAsc(a, b));
+      console.log(res);
+    });
     // this.gun
     //   .getLastTweetFromUser("username")
     //   .then(hash => this.ipfs.fetchTweet(hash))

+ 15 - 13
app/src/pages/profile/profile.ts

@@ -70,7 +70,7 @@ export class ProfilePage {
   }
 
   doRefresh(refresher) {
-    this.loadTimeline(this.user.id).then(res => {
+    this.loadTimeline(this.user.id_str).then(res => {
       if (res.length > 0) {
         // Replace tweets
         this.tweets = res;
@@ -88,19 +88,21 @@ export class ProfilePage {
 
   loadMore(infiniteScroll: InfiniteScroll) {
     if (this.enableInfiniteScroll) {
-      this.loadTimeline(this.user.id, this.oldestLoadedTweetId).then(res => {
-        if (res.length > 0) {
-          // Append loaded tweets
-          this.tweets = this.tweets.concat(res);
-
-          // Save oldest tweet's id for next load more
-          this.oldestLoadedTweetId = res
-            .filter(tweet => !tweet.private_tweet)
-            .reduce((acc, cur) => (acc.id < cur.id ? acc : cur))["id"];
+      this.loadTimeline(this.user.id_str, this.oldestLoadedTweetId).then(
+        res => {
+          if (res.length > 0) {
+            // Append loaded tweets
+            this.tweets = this.tweets.concat(res);
+
+            // Save oldest tweet's id for next load more
+            this.oldestLoadedTweetId = res
+              .filter(tweet => !tweet.private_tweet)
+              .reduce((acc, cur) => (acc.id < cur.id ? acc : cur))["id"];
+          }
+          // Hide loading icon
+          infiniteScroll.complete();
         }
-        // Hide loading icon
-        infiniteScroll.complete();
-      });
+      );
     } else {
       // Hide loading icon
       infiniteScroll.complete();