|
@@ -1,4 +1,4 @@
|
|
-import { Component, Input } from "@angular/core";
|
|
+import { Component, Input, ChangeDetectorRef } from "@angular/core";
|
|
import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
|
|
import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
|
|
|
|
|
|
|
|
|
|
@@ -15,21 +15,28 @@ export class TweetActionsComponent {
|
|
@Input()
|
|
@Input()
|
|
data: any[];
|
|
data: any[];
|
|
|
|
|
|
- constructor(private twitter: TwitterApiProvider) {}
|
|
+ constructor(
|
|
|
|
+ private twitter: TwitterApiProvider,
|
|
|
|
+ private ref: ChangeDetectorRef
|
|
|
|
+ ) {}
|
|
|
|
|
|
like(id) {
|
|
like(id) {
|
|
if (!this.data["private_tweet"]) {
|
|
if (!this.data["private_tweet"]) {
|
|
- this.twitter.likeTweet(id);
|
|
+ this.twitter.likeTweet(id).then(() => {
|
|
- this.data["favorited"] = true;
|
|
+ this.data["favorited"] = true;
|
|
- this.data["favorite_count"]++;
|
|
+ this.data["favorite_count"]++;
|
|
|
|
+ this.ref.detectChanges();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
removeLike(id) {
|
|
removeLike(id) {
|
|
if (!this.data["private_tweet"]) {
|
|
if (!this.data["private_tweet"]) {
|
|
- this.twitter.unlikeTweet(id);
|
|
+ this.twitter.unlikeTweet(id).then(() => {
|
|
- this.data["favorited"] = false;
|
|
+ this.data["favorited"] = false;
|
|
- this.data["favorite_count"]--;
|
|
+ this.data["favorite_count"]--;
|
|
|
|
+ this.ref.detectChanges();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|