Browse Source

Bugfix retweet count on retweeted tweets

Carsten Porth 5 years ago
parent
commit
657e3ebbc3

+ 2 - 2
app/src/components/tweet-actions/tweet-actions.html

@@ -1,12 +1,12 @@
 <!-- Generated template for the TweetActionsComponent component -->
 <div class="actions-container">
-  <div class="retweets" *ngIf="!data.user.protected" (click)="retweetStatus(data.id_str)">
+  <div class="retweets" *ngIf="!data.user.protected" (click)="retweetStatus(id)">
     <ion-icon name="ios-git-compare-outline"></ion-icon>
     <span>{{ data.retweet_count | friendlyNumber }}</span>
   </div>
   <div class="likes" *ngIf="!data.private_tweet">
     <ion-icon *ngIf="data.favorited" name="ios-heart" (click)="removeLike(data.id_str)" color="danger"></ion-icon>
     <ion-icon *ngIf="!data.favorited" name="ios-heart-outline" (click)="like(data.id_str)"></ion-icon>
-    <span>{{ data.favorite_count | friendlyNumber }}</span>
+    <span>{{ favoriteCount | friendlyNumber }}</span>
   </div>
 </div>

+ 16 - 0
app/src/components/tweet-actions/tweet-actions.ts

@@ -23,6 +23,22 @@ export class TweetActionsComponent {
     private navCtrl: NavController
   ) {}
 
+  get favoriteCount() {
+    if (this.data["retweeted_status"]) {
+      return this.data["retweeted_status"]["favorite_count"];
+    } else {
+      return this.data["favorite_count"];
+    }
+  }
+
+  get id() {
+    if (this.data["retweeted_status"]) {
+      return this.data["retweeted_status"]["id_str"];
+    } else {
+      return this.data["id_str"];
+    }
+  }
+
   like(id: string): void {
     if (!this.data["private_tweet"]) {
       this.twitter.likeTweet(id).then(() => {