Update PostComponent, hide edit button after 24 hours. Fixes #2188

This commit is contained in:
Daniel Supernault 2020-05-24 02:48:39 -06:00
parent 369cfd8c76
commit a1fee6a26b
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -42,7 +42,7 @@
</div>
<div v-if="ownerOrAdmin()">
<a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
<a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
<a v-if="canEdit" class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
<a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
</div>
</div>
@ -108,7 +108,7 @@
</span>
<span v-if="ownerOrAdmin()">
<a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
<a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
<a v-if="canEdit" class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
<a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost">Delete</a>
</span>
</div>
@ -675,7 +675,8 @@ export default {
ctxEmbedShowCaption: true,
ctxEmbedShowLikes: false,
ctxEmbedCompactMode: false,
layout: this.profileLayout
layout: this.profileLayout,
canEdit: false
}
},
watch: {
@ -773,6 +774,13 @@ export default {
self.showComments = true;
this.fetchComments();
}
if(this.ownerOrAdmin()) {
let od = new Date(this.status.created_at).getTime() + (1 * 24 * 60 * 60 * 1000);
let now = new Date().getTime();
if(od > now) {
this.canEdit = true;
}
}
this.loaded = true;
}).catch(error => {
swal('Oops!', 'An error occured, please try refreshing the page.', 'error');