handle repost_of object, issue #10

This commit is contained in:
Morgan McMillian 2017-06-25 08:24:11 -07:00
parent a005a2b0e7
commit fe0f12f613

View file

@ -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;