+
@@ -245,9 +245,9 @@ export default {
liked: false,
shared: false
},
- likes: {},
+ likes: [],
likesPage: 1,
- shares: {},
+ shares: [],
sharesPage: 1,
}
},
@@ -267,13 +267,13 @@ export default {
if(this.reactions) {
if(this.reactions.bookmarked == true) {
- $('.far.fa-bookmark').removeClass('far').addClass('fas text-warning');
+ $('.postComponent .far.fa-bookmark').removeClass('far').addClass('fas text-warning');
}
if(this.reactions.shared == true) {
- $('.far.fa-share-square').addClass('text-primary');
+ $('.postComponent .far.fa-share-square').addClass('text-primary');
}
if(this.reactions.liked == true) {
- $('.far.fa-heart ').removeClass('far text-dark').addClass('fas text-danger');
+ $('.postComponent .far.fa-heart').removeClass('far text-dark').addClass('fas text-danger');
}
}
@@ -383,9 +383,9 @@ export default {
page: this.likesPage,
},
}).then(({ data }) => {
- if (data.data.length) {
- this.likesPage += 1;
+ if (data.data.length > 0) {
this.likes.push(...data.data);
+ this.likesPage++;
$state.loaded();
} else {
$state.complete();
@@ -399,9 +399,9 @@ export default {
page: this.sharesPage,
},
}).then(({ data }) => {
- if (data.data.length) {
- this.sharesPage += 1;
+ if (data.data.length > 0) {
this.shares.push(...data.data);
+ this.sharesPage++;
$state.loaded();
} else {
$state.complete();
@@ -420,10 +420,17 @@ export default {
this.status.favourites_count = res.data.count;
if(this.reactions.liked == true) {
this.reactions.liked = false;
+ let user = this.user.id;
+ this.likes = this.likes.filter(function(like) {
+ return like.id !== user;
+ });
} else {
this.reactions.liked = true;
+ let user = this.user;
+ this.likes.push(user);
}
}).catch(err => {
+ console.error(err);
swal('Error', 'Something went wrong, please try again later.', 'error');
});
},
@@ -439,10 +446,17 @@ export default {
this.status.reblogs_count = res.data.count;
if(this.reactions.shared == true) {
this.reactions.shared = false;
+ let user = this.user.id;
+ this.shares = this.shares.filter(function(reaction) {
+ return reaction.id !== user;
+ });
} else {
this.reactions.shared = true;
+ let user = this.user;
+ this.shares.push(user);
}
}).catch(err => {
+ console.error(err);
swal('Error', 'Something went wrong, please try again later.', 'error');
});
},
@@ -495,20 +509,19 @@ export default {
});
},
- deletePost() {
+ deletePost(status) {
var result = confirm('Are you sure you want to delete this post?');
if (result) {
if($('body').hasClass('loggedIn') == false) {
return;
}
-
axios.post('/i/delete', {
- type: 'status',
- item: this.status.id
+ type: 'status',
+ item: status.id
}).then(res => {
- swal('Success', 'You have successfully deleted this post', 'success');
+ swal('Success', 'You have successfully deleted this post', 'success');
}).catch(err => {
- swal('Error', 'Something went wrong. Please try again later.', 'error');
+ swal('Error', 'Something went wrong. Please try again later.', 'error');
});
}
}