Преглед на файлове

Take care of text_range

Carsten Porth преди 6 години
родител
ревизия
b008528626
променени са 2 файла, в които са добавени 10 реда и са изтрити 3 реда
  1. 7 2
      app/src/components/tweet-body/tweet-body.ts
  2. 3 1
      app/src/pages/write-tweet/write-tweet.ts

+ 7 - 2
app/src/components/tweet-body/tweet-body.ts

@@ -18,9 +18,14 @@ export class TweetBodyComponent {
 
   get status(): string {
     if (this.data["retweeted_status"]) {
-      return this.data["retweeted_status"]["full_text"];
+      const range = this.data["retweeted_status"]["display_text_range"];
+      return this.data["retweeted_status"]["full_text"].substr(
+        range[0],
+        range[1]
+      );
     } else {
-      return this.data["full_text"];
+      const range = this.data["display_text_range"];
+      return this.data["full_text"].substr(range[0], range[1]);
     }
   }
 

+ 3 - 1
app/src/pages/write-tweet/write-tweet.ts

@@ -72,11 +72,13 @@ export class WriteTweetPage {
   }
 
   private async buildPrivateTweet() {
+    const status = this.tweet.value["text"].trim();
     return {
-      full_text: this.tweet.value["text"].trim(),
+      full_text: status,
       user_id: await this.storage.get("userId"),
       created_at: Date.now(),
       private_tweet: true,
+      display_text_range: [0, status.length],
       entities: {}
     };
   }