|
@@ -4,7 +4,8 @@ import {
|
|
|
NavController,
|
|
|
NavParams,
|
|
|
Refresher,
|
|
|
- InfiniteScroll
|
|
|
+ InfiniteScroll,
|
|
|
+ Events
|
|
|
} from "ionic-angular";
|
|
|
import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
|
|
|
|
|
@@ -14,25 +15,35 @@ import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
|
|
|
templateUrl: "search-results-tweets-popular.html"
|
|
|
})
|
|
|
export class SearchResultsTweetsPopularPage {
|
|
|
- keyword: string;
|
|
|
+ query: string;
|
|
|
tweets = [];
|
|
|
|
|
|
constructor(
|
|
|
public navCtrl: NavController,
|
|
|
public navParams: NavParams,
|
|
|
- private twitter: TwitterApiProvider
|
|
|
+ private twitter: TwitterApiProvider,
|
|
|
+ private events: Events
|
|
|
) {
|
|
|
- this.keyword = navParams.data;
|
|
|
+ this.query = this.navParams.data;
|
|
|
+
|
|
|
+ this.events.subscribe("query:changed", query => {
|
|
|
+ if (query.length) {
|
|
|
+ this.twitter
|
|
|
+ .searchPopularTweets(query)
|
|
|
+ .then(res => (this.tweets = res));
|
|
|
+ this.query = query;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
async ionViewDidLoad() {
|
|
|
- if (this.keyword.length) {
|
|
|
- this.tweets = await this.twitter.searchPopularTweets(this.keyword);
|
|
|
+ if (this.query.length) {
|
|
|
+ this.tweets = await this.twitter.searchPopularTweets(this.query);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
doRefresh(refresher: Refresher) {
|
|
|
- this.twitter.searchPopularTweets(this.keyword).then(tweets => {
|
|
|
+ this.twitter.searchPopularTweets(this.query).then(tweets => {
|
|
|
this.tweets = tweets;
|
|
|
refresher.complete();
|
|
|
});
|
|
@@ -40,7 +51,7 @@ export class SearchResultsTweetsPopularPage {
|
|
|
|
|
|
loadMore(infiniteScroll: InfiniteScroll) {
|
|
|
this.twitter
|
|
|
- .searchPopularTweets(this.keyword, this.oldestTweet)
|
|
|
+ .searchPopularTweets(this.query, this.oldestTweet)
|
|
|
.then(tweets => {
|
|
|
this.tweets["statuses"] = this.tweets["statuses"].concat(
|
|
|
tweets["statuses"]
|
|
@@ -60,10 +71,10 @@ export class SearchResultsTweetsPopularPage {
|
|
|
}
|
|
|
|
|
|
get enableRefresh() {
|
|
|
- return this.keyword.length > 0;
|
|
|
+ return this.query.length > 0;
|
|
|
}
|
|
|
|
|
|
get enableInfiniteScroll() {
|
|
|
- return this.keyword.length > 0;
|
|
|
+ return this.query.length > 0;
|
|
|
}
|
|
|
}
|