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:
parent
9a5767da58
commit
64ab306b50
1 changed files with 229 additions and 188 deletions
|
@ -1,5 +1,12 @@
|
||||||
<template>
|
<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="container px-0">
|
||||||
<div class="card card-md-rounded-0 status-container orientation-unknown">
|
<div class="card card-md-rounded-0 status-container orientation-unknown">
|
||||||
<div class="row px-0 mx-0">
|
<div class="row px-0 mx-0">
|
||||||
|
@ -189,7 +196,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<b-modal ref="likesModal"
|
<b-modal ref="likesModal"
|
||||||
id="l-modal"
|
id="l-modal"
|
||||||
hide-footer
|
hide-footer
|
||||||
|
@ -338,7 +345,7 @@
|
||||||
pixelfed.postComponent = {};
|
pixelfed.postComponent = {};
|
||||||
|
|
||||||
export default {
|
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() {
|
data() {
|
||||||
return {
|
return {
|
||||||
status: false,
|
status: false,
|
||||||
|
@ -354,20 +361,22 @@ export default {
|
||||||
sharesPage: 1,
|
sharesPage: 1,
|
||||||
lightboxMedia: false,
|
lightboxMedia: false,
|
||||||
replyText: '',
|
replyText: '',
|
||||||
|
relationship: {},
|
||||||
results: [],
|
results: [],
|
||||||
pagination: {},
|
pagination: {},
|
||||||
min_id: 0,
|
min_id: 0,
|
||||||
max_id: 0,
|
max_id: 0,
|
||||||
reply_to_profile_id: 0,
|
reply_to_profile_id: 0,
|
||||||
thread: false,
|
thread: false,
|
||||||
showComments: false
|
showComments: false,
|
||||||
|
warning: false,
|
||||||
|
loaded: false,
|
||||||
|
loading: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchData();
|
this.fetchRelationships();
|
||||||
this.authCheck();
|
|
||||||
let token = $('meta[name="csrf-token"]').attr('content');
|
let token = $('meta[name="csrf-token"]').attr('content');
|
||||||
$('input[name="_token"]').each(function(k, v) {
|
$('input[name="_token"]').each(function(k, v) {
|
||||||
let el = $(v);
|
let el = $(v);
|
||||||
|
@ -395,14 +404,6 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
authCheck() {
|
|
||||||
let authed = $('body').hasClass('loggedIn');
|
|
||||||
if(authed == true) {
|
|
||||||
$('.comment-form-guest').addClass('d-none');
|
|
||||||
$('.comment-form').removeClass('d-none');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
showMuteBlock() {
|
showMuteBlock() {
|
||||||
let sid = this.status.account.id;
|
let sid = this.status.account.id;
|
||||||
let uid = this.user.id;
|
let uid = this.user.id;
|
||||||
|
@ -427,10 +428,6 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchData() {
|
fetchData() {
|
||||||
let loader = this.$loading.show({
|
|
||||||
'opacity': 0,
|
|
||||||
'background-color': '#f5f8fa'
|
|
||||||
});
|
|
||||||
axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
|
axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
@ -444,7 +441,6 @@ export default {
|
||||||
self.sharesPage = 2;
|
self.sharesPage = 2;
|
||||||
//this.buildPresenter();
|
//this.buildPresenter();
|
||||||
this.showMuteBlock();
|
this.showMuteBlock();
|
||||||
loader.hide();
|
|
||||||
pixelfed.readmore();
|
pixelfed.readmore();
|
||||||
if(self.status.comments_disabled == false) {
|
if(self.status.comments_disabled == false) {
|
||||||
self.showComments = true;
|
self.showComments = true;
|
||||||
|
@ -694,16 +690,19 @@ export default {
|
||||||
swal('Something went wrong!', 'Please try again later', 'error');
|
swal('Something went wrong!', 'Please try again later', 'error');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
l(e) {
|
l(e) {
|
||||||
let len = e.length;
|
let len = e.length;
|
||||||
if(len < 10) { return e; }
|
if(len < 10) { return e; }
|
||||||
return e.substr(0, 10)+'...';
|
return e.substr(0, 10)+'...';
|
||||||
},
|
},
|
||||||
|
|
||||||
replyFocus(e) {
|
replyFocus(e) {
|
||||||
this.reply_to_profile_id = e.account.id;
|
this.reply_to_profile_id = e.account.id;
|
||||||
this.replyText = '@' + e.account.username + ' ';
|
this.replyText = '@' + e.account.username + ' ';
|
||||||
$('textarea[name="comment"]').focus();
|
$('textarea[name="comment"]').focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchComments() {
|
fetchComments() {
|
||||||
let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
|
let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
|
||||||
axios.get(url)
|
axios.get(url)
|
||||||
|
@ -741,6 +740,7 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
loadMore(e) {
|
loadMore(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
|
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;
|
this.pagination = response.data.meta.pagination;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
likeReply(status, $event) {
|
likeReply(status, $event) {
|
||||||
if($('body').hasClass('loggedIn') == false) {
|
if($('body').hasClass('loggedIn') == false) {
|
||||||
return;
|
return;
|
||||||
|
@ -778,11 +779,13 @@ export default {
|
||||||
swal('Error', 'Something went wrong, please try again later.', 'error');
|
swal('Error', 'Something went wrong, please try again later.', 'error');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
truncate(str,lim) {
|
truncate(str,lim) {
|
||||||
return _.truncate(str,{
|
return _.truncate(str,{
|
||||||
length: lim
|
length: lim
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
timeAgo(ts) {
|
timeAgo(ts) {
|
||||||
let date = Date.parse(ts);
|
let date = Date.parse(ts);
|
||||||
let seconds = Math.floor((new Date() - date) / 1000);
|
let seconds = Math.floor((new Date() - date) / 1000);
|
||||||
|
@ -852,7 +855,45 @@ export default {
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue