diff --git a/resources/assets/js/components/PostComments.vue b/resources/assets/js/components/PostComments.vue
index 25ed738f7..7b62c54f5 100644
--- a/resources/assets/js/components/PostComments.vue
+++ b/resources/assets/js/components/PostComments.vue
@@ -1,69 +1,26 @@
-
-
- {{comment.account.username}} + {{l(comment.account.username)}}
@@ -102,6 +59,11 @@ export default {
embed(e) {
pixelfed.embed.build(e);
},
+ l(e) {
+ let len = e.length;
+ if(len < 10) { return e; }
+ return e.substr(0, 10)+'...';
+ },
reply(e) {
this.reply_to_profile_id = e.account.id;
$('.comment-form input[name=comment]').val('@'+e.account.username+' ');
@@ -114,11 +76,33 @@ export default {
let self = this;
this.results = response.data.data;
this.pagination = response.data.meta.pagination;
- $('.lwrapper').addClass('d-none');
- $('.cwrapper').removeClass('d-none');
+ $('.postCommentsLoader').addClass('d-none');
+ $('.postCommentsContainer').removeClass('d-none');
}).catch(error => {
- $('.lds-ring').attr('style','width:100%').addClass('pt-4 font-weight-bold text-muted').text('An error occured, cannot fetch comments. Please try again later.');
+ if(!error.response) {
+ $('.postCommentsLoader .lds-ring')
+ .attr('style','width:100%')
+ .addClass('pt-4 font-weight-bold text-muted')
+ .text('An error occured, cannot fetch comments. Please try again later.');
console.log(error);
+ } else {
+ switch(error.response.status) {
+ case 401:
+ $('.postCommentsLoader .lds-ring')
+ .attr('style','width:100%')
+ .addClass('pt-4 font-weight-bold text-muted')
+ .text('Please login to view.');
+ break;
+
+ default:
+ $('.postCommentsLoader .lds-ring')
+ .attr('style','width:100%')
+ .addClass('pt-4 font-weight-bold text-muted')
+ .text('An error occured, cannot fetch comments. Please try again later.');
+ break;
+ }
+ console.log(error.response.status);
+ }
});
},
loadMore(e) {
@@ -127,18 +111,18 @@ export default {
$('.load-more-link').addClass('d-none');
return;
}
- $('.cwrapper').addClass('d-none');
- $('.lwrapper').removeClass('d-none');
+ $('.postCommentsContainer').addClass('d-none');
+ $('.postCommentsLoader').removeClass('d-none');
let next = this.pagination.links.next;
axios.get(next)
.then(response => {
let self = this;
let res = response.data.data;
- $('.lwrapper').addClass('d-none');
+ $('.postCommentsLoader').addClass('d-none');
for(let i=0; i < res.length; i++) {
this.results.unshift(res[i]);
}
- $('.cwrapper').removeClass('d-none');
+ $('.postCommentsContainer').removeClass('d-none');
this.pagination = response.data.meta.pagination;
});
}