Update Timeline.vue and Profile.vue

This commit is contained in:
Daniel Supernault 2019-05-07 00:00:13 -06:00
parent ae4f9dd3fc
commit 3f709776f2
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 22 additions and 7 deletions

View file

@ -516,6 +516,7 @@ export default {
], ],
data() { data() {
return { return {
ids: [],
profile: {}, profile: {},
user: {}, user: {},
timeline: [], timeline: [],
@ -568,6 +569,7 @@ export default {
.then(res => { .then(res => {
let data = res.data; let data = res.data;
let ids = data.map(status => status.id); let ids = data.map(status => status.id);
this.ids = ids;
this.min_id = Math.max(...ids); this.min_id = Math.max(...ids);
this.max_id = Math.min(...ids); this.max_id = Math.min(...ids);
this.modalStatus = _.first(res.data); this.modalStatus = _.first(res.data);
@ -601,9 +603,15 @@ export default {
}).then(res => { }).then(res => {
if (res.data.length && this.loading == false) { if (res.data.length && this.loading == false) {
let data = res.data; let data = res.data;
let ids = data.map(status => status.id); let self = this;
this.max_id = Math.min(...ids); data.forEach(d => {
this.timeline.push(...data); if(self.ids.indexOf(d.id) == -1) {
self.timeline.push(d);
self.ids.push(d.id);
}
});
this.min_id = Math.max(...this.ids);
this.max_id = Math.min(...this.ids);
$state.loaded(); $state.loaded();
this.loading = false; this.loading = false;
} else { } else {

View file

@ -430,6 +430,7 @@
props: ['scope'], props: ['scope'],
data() { data() {
return { return {
ids: [],
config: {}, config: {},
page: 2, page: 2,
feed: [], feed: [],
@ -544,6 +545,7 @@
let data = res.data; let data = res.data;
this.feed.push(...data); this.feed.push(...data);
let ids = data.map(status => status.id); let ids = data.map(status => status.id);
this.ids = ids;
this.min_id = Math.max(...ids); this.min_id = Math.max(...ids);
this.max_id = Math.min(...ids); this.max_id = Math.min(...ids);
$('.timeline .pagination').removeClass('d-none'); $('.timeline .pagination').removeClass('d-none');
@ -579,10 +581,15 @@
}).then(res => { }).then(res => {
if (res.data.length && this.loading == false) { if (res.data.length && this.loading == false) {
let data = res.data; let data = res.data;
this.feed.push(...data); let self = this;
let ids = data.map(status => status.id); data.forEach(d => {
this.min_id = Math.max(...ids); if(self.ids.indexOf(d.id) == -1) {
this.max_id = Math.min(...ids); self.feed.push(d);
self.ids.push(d.id);
}
});
this.min_id = Math.max(...this.ids);
this.max_id = Math.min(...this.ids);
this.page += 1; this.page += 1;
$state.loaded(); $state.loaded();
this.loading = false; this.loading = false;