From fe0f12f613a42ec6fde374fb7903aa6ecfb4e90f Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sun, 25 Jun 2017 08:24:11 -0700 Subject: [PATCH] handle repost_of object, issue #10 --- src/pages/stream/stream.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/pages/stream/stream.ts b/src/pages/stream/stream.ts index 6f4973c..164017d 100644 --- a/src/pages/stream/stream.ts +++ b/src/pages/stream/stream.ts @@ -56,7 +56,7 @@ export class StreamPage { } fetchOlderPosts(infiniteScroll) { - let params = {include_raw: 1, before_id: this.before_id, count: 40}; + let params = {include_raw: 1, include_reposted_by:1, before_id: this.before_id, count: 40}; if (this.title === 'Mentions') { this.fcaller = this.fetcher('me', params); } else { @@ -64,6 +64,11 @@ export class StreamPage { } this.fcaller.then(res => { if (res.data.length > 0) { + for (var i = 0; i < res.data.length; i++) { + if (res.data[i]['repost_of']) { + res.data[i] = res.data[i]['repost_of'] + } + } this.posts.push.apply(this.posts, res.data); this.before_id = res.meta.min_id; } @@ -76,7 +81,7 @@ export class StreamPage { } fetchNewerPosts(refresher) { - let params = {include_raw: 1, since_id: this.since_id, count: 40}; + let params = {include_raw: 1, include_reposted_by: 1, since_id: this.since_id, count: 40}; if (this.title === 'Mentions') { this.fcaller = this.fetcher('me', params); } else { @@ -84,6 +89,11 @@ export class StreamPage { } this.fcaller.then(res => { if (res.data.length > 0) { + for (var i = 0; i < res.data.length; i++) { + if (res.data[i]['repost_of']) { + res.data[i] = res.data[i]['repost_of'] + } + } Array.prototype.unshift.apply(this.posts, res.data); this.since_id = res.meta.max_id; } @@ -96,8 +106,12 @@ export class StreamPage { } fetchPosts() { - console.log('-- fetching global stream --'); - this.fetcher({include_raw: 1, count: 40}).then(res => { + this.fetcher({include_raw: 1, include_reposted_by: 1, count: 40}).then(res => { + for (var i = 0; i < res.data.length; i++) { + if (res.data[i]['repost_of']) { + res.data[i] = res.data[i]['repost_of'] + } + } this.posts = res.data; this.since_id = res.meta.max_id; this.before_id = res.meta.min_id;