Carsten Porth пре 5 година
родитељ
комит
152b3fda07

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

@@ -1,6 +1,6 @@
 <!-- Generated template for the TweetBodyComponent component -->
 <div>
-  <p [innerHTML]="text | replaceUrls: entities.urls | replaceHashtags: entities.hashtags"></p>
+  <p [innerHTML]="status | replaceUrls: entities.urls | replaceHashtags: entities.hashtags"></p>
   <img *ngIf="hasPhoto" src="{{ entities.media[0]['media_url_https'] }}" alt="Photo" class="photo">
   <quoted-status *ngIf="data.quoted_status" [data]="data.quoted_status"></quoted-status>
 </div>

+ 11 - 3
app/src/components/tweet-body/tweet-body.ts

@@ -16,12 +16,20 @@ export class TweetBodyComponent {
 
   constructor() {}
 
-  get text(): string {
-    return this.data["full_text"];
+  get status(): string {
+    if(this.data["retweeted_status"]) {
+      return this.data["retweeted_status"]["full_text"];
+    } else {
+      return this.data["full_text"];
+    }
   }
 
   get entities(){
-    return this.data["entities"];
+    if(this.data["retweeted_status"]) {
+      return this.data["retweeted_status"]["entities"];
+    } else {
+      return this.data["entities"];
+    }
   }
 
   get hasPhoto() {

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

@@ -1,5 +1,6 @@
 <ion-item text-wrap>
-  <tweet-header [user]="data.user" [tweetCreatedAt]="data.created_at"></tweet-header>
+  <p *ngIf="data.retweeted_status" class="retweet-info">{{ data.user.name }} has retweeted:</p>
+  <tweet-header [user]="user" [tweetCreatedAt]="createdAt"></tweet-header>
   <tweet-body [data]="data"></tweet-body>
   <tweet-actions [data]="data"></tweet-actions>
 </ion-item>

+ 6 - 2
app/src/components/tweet/tweet.scss

@@ -1,3 +1,7 @@
 tweet {
-
-}
+    .retweet-info {
+        font-weight: 250;
+        font-size: 10px;
+        margin-bottom: 8px;
+    }
+}

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

@@ -16,4 +16,20 @@ export class TweetComponent {
 
   constructor() {}
 
+  get user() {
+    if(this.data["retweeted_status"]) {
+      return this.data["retweeted_status"]["user"];
+    } else {
+      return this.data["user"];
+    }
+  }
+
+  get createdAt() {
+    if(this.data["retweeted_status"]) {
+      return this.data["retweeted_status"]["created_at"];
+    } else {
+      return this.data["created_at"];
+    }
+  }
+
 }