1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Update PostComponent

This commit is contained in:
Daniel Supernault 2019-04-08 01:11:35 -06:00
parent 9a5767da58
commit 64ab306b50
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -1,5 +1,12 @@
<template>
<div class="postComponent d-none">
<div>
<div v-if="loaded && warning" class="bg-white pt-3 border-bottom">
<div class="container">
<p class="text-center font-weight-bold">You are blocking this account</p>
<p class="text-center font-weight-bold">Click <a href="#" class="cursor-pointer" @click.prevent="warning = false; fetchData()">here</a> to view this status</p>
</div>
</div>
<div v-if="loaded && warning == false" class="postComponent">
<div class="container px-0">
<div class="card card-md-rounded-0 status-container orientation-unknown">
<div class="row px-0 mx-0">
@ -189,7 +196,7 @@
</div>
</div>
</div>
</div>
<b-modal ref="likesModal"
id="l-modal"
hide-footer
@ -338,7 +345,7 @@
pixelfed.postComponent = {};
export default {
props: ['status-id', 'status-username', 'status-template', 'status-url', 'status-profile-url', 'status-avatar'],
props: ['status-id', 'status-username', 'status-template', 'status-url', 'status-profile-url', 'status-avatar', 'status-profile-id'],
data() {
return {
status: false,
@ -354,20 +361,22 @@ export default {
sharesPage: 1,
lightboxMedia: false,
replyText: '',
relationship: {},
results: [],
pagination: {},
min_id: 0,
max_id: 0,
reply_to_profile_id: 0,
thread: false,
showComments: false
showComments: false,
warning: false,
loaded: false,
loading: null
}
},
mounted() {
this.fetchData();
this.authCheck();
this.fetchRelationships();
let token = $('meta[name="csrf-token"]').attr('content');
$('input[name="_token"]').each(function(k, v) {
let el = $(v);
@ -395,14 +404,6 @@ export default {
},
methods: {
authCheck() {
let authed = $('body').hasClass('loggedIn');
if(authed == true) {
$('.comment-form-guest').addClass('d-none');
$('.comment-form').removeClass('d-none');
}
},
showMuteBlock() {
let sid = this.status.account.id;
let uid = this.user.id;
@ -427,10 +428,6 @@ export default {
},
fetchData() {
let loader = this.$loading.show({
'opacity': 0,
'background-color': '#f5f8fa'
});
axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
.then(response => {
let self = this;
@ -444,7 +441,6 @@ export default {
self.sharesPage = 2;
//this.buildPresenter();
this.showMuteBlock();
loader.hide();
pixelfed.readmore();
if(self.status.comments_disabled == false) {
self.showComments = true;
@ -694,16 +690,19 @@ export default {
swal('Something went wrong!', 'Please try again later', 'error');
});
},
l(e) {
let len = e.length;
if(len < 10) { return e; }
return e.substr(0, 10)+'...';
},
replyFocus(e) {
this.reply_to_profile_id = e.account.id;
this.replyText = '@' + e.account.username + ' ';
$('textarea[name="comment"]').focus();
},
fetchComments() {
let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
axios.get(url)
@ -741,6 +740,7 @@ export default {
}
});
},
loadMore(e) {
e.preventDefault();
if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
@ -760,6 +760,7 @@ export default {
this.pagination = response.data.meta.pagination;
});
},
likeReply(status, $event) {
if($('body').hasClass('loggedIn') == false) {
return;
@ -778,11 +779,13 @@ export default {
swal('Error', 'Something went wrong, please try again later.', 'error');
});
},
truncate(str,lim) {
return _.truncate(str,{
length: lim
});
},
timeAgo(ts) {
let date = Date.parse(ts);
let seconds = Math.floor((new Date() - date) / 1000);
@ -852,7 +855,45 @@ export default {
return;
});
}
},
fetchRelationships() {
let loader = this.$loading.show({
'opacity': 0,
'background-color': '#f5f8fa'
});
if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
this.loaded = true;
loader.hide();
this.fetchData();
return;
} else {
axios.get('/api/v1/accounts/relationships', {
params: {
'id[]': this.statusProfileId
}
}).then(res => {
if(res.data[0] == null) {
this.loaded = true;
loader.hide();
this.fetchData();
return;
}
this.relationship = res.data[0];
if(res.data[0].blocking == true) {
this.loaded = true;
loader.hide();
this.warning = true;
return;
} else {
this.loaded = true;
loader.hide();
this.fetchData();
return;
}
});
}
},
},
}