Update Timeline component, add inline reports modal

This commit is contained in:
Daniel Supernault 2021-02-15 20:27:20 -07:00
parent 3dfb8738a2
commit e64b4bd382
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -469,6 +469,7 @@
</div> </div>
</div> </div>
</div> </div>
<b-modal ref="ctxModal" <b-modal ref="ctxModal"
id="ctx-modal" id="ctx-modal"
hide-header hide-header
@ -478,15 +479,15 @@
size="sm" size="sm"
body-class="list-group-flush p-0 rounded"> body-class="list-group-flush p-0 rounded">
<div class="list-group text-center"> <div class="list-group text-center">
<div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id" class="list-group-item rounded cursor-pointer font-weight-bold text-danger" @click="ctxMenuReportPost()">Report</div> <!-- <div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id && ctxMenuRelationship && ctxMenuRelationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-danger" @click="ctxMenuUnfollow()">Unfollow</div>
<div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id && ctxMenuRelationship && ctxMenuRelationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-danger" @click="ctxMenuUnfollow()">Unfollow</div> <div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id && ctxMenuRelationship && !ctxMenuRelationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-primary" @click="ctxMenuFollow()">Follow</div> -->
<div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id && ctxMenuRelationship && !ctxMenuRelationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-primary" @click="ctxMenuFollow()">Follow</div> <div class="list-group-item rounded cursor-pointer" @click="ctxMenuGoToPost()">View Post</div>
<div class="list-group-item rounded cursor-pointer" @click="ctxMenuGoToPost()">Go to post</div> <!-- <div v-if="ctxMenuStatus && ctxMenuStatus.local == true && !ctxMenuStatus.in_reply_to_id" class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div>
<div v-if="ctxMenuStatus && ctxMenuStatus.local == true && !ctxMenuStatus.in_reply_to_id" class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div> <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div> -->
<!-- <div class="list-group-item rounded cursor-pointer" @click="ctxMenuShare()">Share</div> --> <div class="list-group-item rounded cursor-pointer" @click="ctxMenuShare()">Share</div>
<div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div> <div v-if="ctxMenuStatus && profile && profile.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenuShow()">Moderation Tools</div>
<div v-if="profile && profile.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenuShow()">Moderation Tools</div> <div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id" class="list-group-item rounded cursor-pointer text-danger" @click="ctxMenuReportPost()">Report</div>
<div v-if="ctxMenuStatus && (profile.is_admin || profile.id == ctxMenuStatus.account.id)" class="list-group-item rounded cursor-pointer" @click="deletePost(ctxMenuStatus)">Delete</div> <div v-if="ctxMenuStatus && (profile.is_admin || profile.id == ctxMenuStatus.account.id)" class="list-group-item rounded cursor-pointer text-danger" @click="deletePost(ctxMenuStatus)">Delete</div>
<div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div> <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
</div> </div>
</b-modal> </b-modal>
@ -499,27 +500,53 @@ rounded
size="sm" size="sm"
body-class="list-group-flush p-0 rounded"> body-class="list-group-flush p-0 rounded">
<div class="list-group text-center"> <div class="list-group text-center">
<p class="py-2 px-3 mb-0">
<div class="text-center font-weight-bold text-danger">Moderation Tools</div>
<div class="small text-center text-muted">Select one of the following options</div>
</p>
<div class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'unlist')">Unlist from Timelines</div> <div class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'unlist')">Unlist from Timelines</div>
<div v-if="ctxMenuStatus.sensitive" class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'remcw')">Remove Content Warning</div> <div v-if="ctxMenuStatus.sensitive" class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'remcw')">Remove Content Warning</div>
<div v-else class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'addcw')">Add Content Warning</div> <div v-else class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'addcw')">Add Content Warning</div>
<!-- <div class="list-group-item rounded cursor-pointer" @click="ctxModOtherMenuShow()">Other</div> -->
<div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div> <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
</div> </div>
</b-modal> </b-modal>
<b-modal ref="ctxModOtherModal"
id="ctx-mod-other-modal"
hide-header
hide-footer
centered
rounded
size="sm"
body-class="list-group-flush p-0 rounded">
<div class="list-group text-center">
<p class="py-2 px-3 mb-0">
<div class="text-center font-weight-bold text-danger">Moderation Tools</div>
<div class="small text-center text-muted">Select one of the following options</div>
</p>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="confirmModal()">Unlist Posts</div>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="confirmModal()">Moderation Log</div>
<div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModOtherMenuClose()">Cancel</div>
</div>
</b-modal>
<b-modal ref="ctxShareModal" <b-modal ref="ctxShareModal"
id="ctx-share-modal" id="ctx-share-modal"
title="Share" title="Share"
hide-footer hide-footer
hide-header
centered centered
rounded rounded
size="sm" size="sm"
body-class="list-group-flush p-0 rounded text-center"> body-class="list-group-flush p-0 rounded text-center">
<div class="list-group-item rounded cursor-pointer border-top-0">Email</div> <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
<div v-if="ctxMenuStatus && ctxMenuStatus.local == true && !ctxMenuStatus.in_reply_to_id" class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div>
<!-- <div class="list-group-item rounded cursor-pointer border-top-0">Email</div>
<div class="list-group-item rounded cursor-pointer">Facebook</div> <div class="list-group-item rounded cursor-pointer">Facebook</div>
<div class="list-group-item rounded cursor-pointer">Mastodon</div> <div class="list-group-item rounded cursor-pointer">Mastodon</div>
<div class="list-group-item rounded cursor-pointer">Pinterest</div> <div class="list-group-item rounded cursor-pointer">Pinterest</div>
<div class="list-group-item rounded cursor-pointer">Pixelfed</div> <div class="list-group-item rounded cursor-pointer">Pixelfed</div>
<div class="list-group-item rounded cursor-pointer">Twitter</div> <div class="list-group-item rounded cursor-pointer">Twitter</div>
<div class="list-group-item rounded cursor-pointer">VK</div> <div class="list-group-item rounded cursor-pointer">VK</div> -->
<div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div> <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div>
</b-modal> </b-modal>
<b-modal ref="ctxEmbedModal" <b-modal ref="ctxEmbedModal"
@ -559,9 +586,68 @@ body-class="p-2 rounded">
<p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p> <p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
</div> </div>
</b-modal> </b-modal>
<b-modal <b-modal ref="ctxReport"
id="ctx-report"
hide-header
hide-footer
centered
rounded
size="sm"
body-class="list-group-flush p-0 rounded">
<p class="py-2 px-3 mb-0">
<div class="text-center font-weight-bold text-danger">Report</div>
<div class="small text-center text-muted">Select one of the following options</div>
</p>
<div class="list-group text-center">
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('spam')">Spam</div>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('sensitive')">Sensitive Content</div>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('abusive')">Abusive or Harmful</div>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="openCtxReportOtherMenu()">Other</div>
<!-- <div class="list-group-item rounded cursor-pointer" @click="ctxReportMenuGoBack()">Go Back</div> -->
<div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxReportMenuGoBack()">Cancel</div>
</div>
</b-modal>
<b-modal ref="ctxReportOther"
id="ctx-report-other"
hide-header
hide-footer
centered
rounded
size="sm"
body-class="list-group-flush p-0 rounded">
<p class="py-2 px-3 mb-0">
<div class="text-center font-weight-bold text-danger">Report</div>
<div class="small text-center text-muted">Select one of the following options</div>
</p>
<div class="list-group text-center">
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('underage')">Underage Account</div>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('copyright')">Copyright Infringement</div>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('impersonation')">Impersonation</div>
<div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('scam')">Scam or Fraud</div>
<!-- <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('terrorism')">Terrorism Related</div> -->
<!-- <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('other')">Other or Not listed</div> -->
<!-- <div class="list-group-item rounded cursor-pointer" @click="ctxReportOtherMenuGoBack()">Go Back</div> -->
<div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxReportOtherMenuGoBack()">Cancel</div>
</div>
</b-modal>
<b-modal ref="ctxConfirm"
id="ctx-confirm"
hide-header
hide-footer
centered
rounded
size="sm"
body-class="list-group-flush p-0 rounded">
<div class="d-flex align-items-center justify-content-center py-3">
<div>{{ this.confirmModalTitle }}</div>
</div>
<div class="d-flex border-top btn-group btn-group-block rounded-0" role="group">
<button type="button" class="btn btn-outline-lighter border-left-0 border-top-0 border-bottom-0 border-right py-2" style="color: rgb(0,122,255) !important;" @click.prevent="confirmModalCancel()">Cancel</button>
<button type="button" class="btn btn-outline-lighter border-0" style="color: rgb(0,122,255) !important;" @click.prevent="confirmModalConfirm()">Confirm</button>
</div>
</b-modal>
<b-modal ref="lightboxModal"
id="lightbox" id="lightbox"
ref="lightboxModal"
hide-header hide-header
hide-footer hide-footer
centered centered
@ -602,11 +688,7 @@ body-class="p-2 rounded">
<input type="checkbox" class="custom-control-input" id="replyModalCWSwitch" v-model="replyNsfw"> <input type="checkbox" class="custom-control-input" id="replyModalCWSwitch" v-model="replyNsfw">
<label :class="[replyNsfw ? 'custom-control-label font-weight-bold text-dark':'custom-control-label text-lighter']" for="replyModalCWSwitch">Mark as NSFW</label> <label :class="[replyNsfw ? 'custom-control-label font-weight-bold text-dark':'custom-control-label text-lighter']" for="replyModalCWSwitch">Mark as NSFW</label>
</div> </div>
<!-- <select class="custom-select custom-select-sm my-0 mr-2">
<option value="public" selected="">Public</option>
<option value="unlisted">Unlisted</option>
<option value="followers">Followers Only</option>
</select> -->
<button class="btn btn-primary btn-sm py-2 px-4 lead text-uppercase font-weight-bold" v-on:click.prevent="commentSubmit(status, $event)" :disabled="replyText.length == 0"> <button class="btn btn-primary btn-sm py-2 px-4 lead text-uppercase font-weight-bold" v-on:click.prevent="commentSubmit(status, $event)" :disabled="replyText.length == 0">
{{replySending == true ? 'POSTING' : 'POST'}} {{replySending == true ? 'POSTING' : 'POST'}}
</button> </button>
@ -614,6 +696,26 @@ body-class="p-2 rounded">
</div> </div>
</div> </div>
</b-modal> </b-modal>
<b-modal ref="ctxStatusModal"
id="ctx-status-modal"
hide-header
hide-footer
centered
rounded
size="xl"
body-class="list-group-flush p-0 m-0 rounded">
<!-- <post-component
v-if="ctxMenuStatus"
:status-template="ctxMenuStatus.pf_type"
:status-id="ctxMenuStatus.id"
:status-username="ctxMenuStatus.account.username"
:status-url="ctxMenuStatus.url"
:status-profile-url="ctxMenuStatus.account.url"
:status-avatar="ctxMenuStatus.account.avatar"
:status-profile-id="ctxMenuStatus.account.id"
profile-layout="metro">
</post-component> -->
</b-modal>
</div> </div>
</template> </template>
@ -739,7 +841,10 @@ body-class="p-2 rounded">
mpData: false, mpData: false,
mpInterval: 15000, mpInterval: 15000,
mpEnabled: false, mpEnabled: false,
mpPoller: null mpPoller: null,
confirmModalTitle: 'Are you sure?',
confirmModalIdentifer: null,
confirmModalType: false
} }
}, },
@ -1090,7 +1195,7 @@ body-class="p-2 rounded">
this.feed = this.feed.filter(s => { this.feed = this.feed.filter(s => {
return s.id != status.id; return s.id != status.id;
}); });
this.$refs.ctxModal.hide(); this.closeModals();
}).catch(err => { }).catch(err => {
swal('Error', 'Something went wrong. Please try again later.', 'error'); swal('Error', 'Something went wrong. Please try again later.', 'error');
}); });
@ -1473,12 +1578,15 @@ body-class="p-2 rounded">
this.ctxMenuStatus = false; this.ctxMenuStatus = false;
this.ctxMenuRelationship = false; this.ctxMenuRelationship = false;
this.$refs.ctxModal.hide(); this.$refs.ctxModal.hide();
this.$refs.ctxReport.hide();
this.$refs.ctxReportOther.hide();
this.closeModals();
}, },
ctxMenuCopyLink() { ctxMenuCopyLink() {
let status = this.ctxMenuStatus; let status = this.ctxMenuStatus;
navigator.clipboard.writeText(status.url); navigator.clipboard.writeText(status.url);
this.closeCtxMenu(); this.closeModals();
return; return;
}, },
@ -1521,11 +1629,14 @@ body-class="p-2 rounded">
}, },
ctxMenuReportPost() { ctxMenuReportPost() {
window.location.href = '/i/report?type=post&id=' + this.ctxMenuStatus.id; this.$refs.ctxModal.hide();
this.$refs.ctxReport.show();
return;
// window.location.href = '/i/report?type=post&id=' + this.ctxMenuStatus.id;
}, },
ctxMenuEmbed() { ctxMenuEmbed() {
this.$refs.ctxModal.hide(); this.closeModals();
this.$refs.ctxEmbedModal.show(); this.$refs.ctxEmbedModal.show();
}, },
@ -1552,13 +1663,24 @@ body-class="p-2 rounded">
this.$refs.ctxModModal.show(); this.$refs.ctxModModal.show();
}, },
ctxModOtherMenuShow() {
this.$refs.ctxModal.hide();
this.$refs.ctxModModal.hide();
this.$refs.ctxModOtherModal.show();
},
ctxModMenu() { ctxModMenu() {
this.$refs.ctxModal.hide(); this.$refs.ctxModal.hide();
}, },
ctxModMenuClose() { ctxModMenuClose() {
this.$refs.ctxModal.hide(); this.closeModals();
this.$refs.ctxModModal.hide(); this.$refs.ctxModal.show();
},
ctxModOtherMenuClose() {
this.closeModals();
this.$refs.ctxModModal.show();
}, },
formatCount(count) { formatCount(count) {
@ -1703,11 +1825,113 @@ body-class="p-2 rounded">
labelRedirect(type) { labelRedirect(type) {
let url = '/i/redirect?url=' + encodeURI(this.config.features.label.covid.url); let url = '/i/redirect?url=' + encodeURI(this.config.features.label.covid.url);
window.location.href = url; window.location.href = url;
},
openCtxReportOtherMenu() {
let s = this.ctxMenuStatus;
this.closeCtxMenu();
this.ctxMenuStatus = s;
this.$refs.ctxReportOther.show();
},
ctxReportMenuGoBack() {
this.$refs.ctxReportOther.hide();
this.$refs.ctxReport.hide();
this.$refs.ctxModal.show();
},
ctxReportOtherMenuGoBack() {
this.$refs.ctxReportOther.hide();
this.$refs.ctxModal.hide();
this.$refs.ctxReport.show();
},
sendReport(type) {
let id = this.ctxMenuStatus.id;
swal({
'title': 'Confirm Report',
'text': 'Are you sure you want to report this post?',
'icon': 'warning',
'buttons': true,
'dangerMode': true
}).then((res) => {
if(res) {
axios.post('/i/report/', {
'report': type,
'type': 'post',
'id': id,
}).then(res => {
this.closeCtxMenu();
swal('Report Sent!', 'We have successfully received your report.', 'success');
}).catch(err => {
swal('Oops!', 'There was an issue reporting this post.', 'error');
})
} else {
this.closeCtxMenu();
}
});
},
closeModals() {
this.$refs.ctxModal.hide();
this.$refs.ctxModModal.hide();
this.$refs.ctxModOtherModal.hide();
this.$refs.ctxShareModal.hide();
this.$refs.ctxEmbedModal.hide();
this.$refs.ctxReport.hide();
this.$refs.ctxReportOther.hide();
this.$refs.ctxConfirm.hide();
this.$refs.lightboxModal.hide();
this.$refs.replyModal.hide();
this.$refs.ctxStatusModal.hide();
},
openCtxStatusModal() {
this.closeModals();
this.$refs.ctxStatusModal.show();
},
openConfirmModal() {
this.closeModals();
this.$refs.ctxConfirm.show();
},
closeConfirmModal() {
this.closeModals();
this.confirmModalTitle = 'Are you sure?';
this.confirmModalType = false;
this.confirmModalIdentifer = null;
},
confirmModalConfirm() {
switch(this.confirmModalType) {
case 'post.delete':
axios.post('/i/delete', {
type: 'status',
item: this.confirmModalIdentifer
}).then(res => {
this.feed = this.feed.filter(s => {
return s.id != this.confirmModalIdentifer;
});
this.closeConfirmModal();
}).catch(err => {
this.closeConfirmModal();
swal('Error', 'Something went wrong. Please try again later.', 'error');
});
break;
}
this.closeConfirmModal();
},
confirmModalCancel() {
this.closeConfirmModal();
} }
}, },
beforeDestroy () { beforeDestroy () {
clearInterval(this.mpInterval); clearInterval(this.mpInterval);
}, }
} }
</script> </script>