Hide repost and like buttons when user is not logged in
This commit is contained in:
parent
d1ac840e4a
commit
6e9ea6f4c4
3 changed files with 12 additions and 1 deletions
|
@ -33,6 +33,7 @@ export interface Post {
|
|||
content: string;
|
||||
in_reply_to_id: string | null;
|
||||
reblog: Post | null;
|
||||
visibility: "public" | "direct";
|
||||
replies_count: number;
|
||||
favourites_count: number;
|
||||
reblogs_count: number;
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<img :src="require('@/assets/tabler/arrow-forward.svg')">
|
||||
</a>
|
||||
<a
|
||||
v-if="canRepost()"
|
||||
class="icon"
|
||||
:class="{ 'highlighted': post.reblogged }"
|
||||
title="Repost"
|
||||
|
@ -73,6 +74,7 @@
|
|||
<span>{{ post.reblogs_count }}</span>
|
||||
</a>
|
||||
<a
|
||||
v-if="canLike()"
|
||||
class="icon"
|
||||
:class="{ 'highlighted': post.favourited }"
|
||||
title="Like"
|
||||
|
@ -267,6 +269,10 @@ export default class PostComponent extends Vue {
|
|||
this.$emit("comment-created", post)
|
||||
}
|
||||
|
||||
canRepost(): boolean {
|
||||
return this.store.currentUser !== null && this.post.visibility === "public"
|
||||
}
|
||||
|
||||
async toggleRepost() {
|
||||
if (!this.store.currentUser) {
|
||||
return
|
||||
|
@ -287,6 +293,10 @@ export default class PostComponent extends Vue {
|
|||
this.post.reblogged = post.reblogged
|
||||
}
|
||||
|
||||
canLike(): boolean {
|
||||
return this.store.currentUser !== null
|
||||
}
|
||||
|
||||
async toggleLike() {
|
||||
if (!this.store.currentUser) {
|
||||
return
|
||||
|
|
|
@ -27,7 +27,7 @@ const props = defineProps<{
|
|||
}>()
|
||||
const emit = defineEmits<{(event: "load-next-page", maxId: string): void}>()
|
||||
|
||||
const initialPostCount: number | null = null
|
||||
let initialPostCount: number | null = null
|
||||
|
||||
watch(() => props.posts.length, (postCount) => {
|
||||
if (initialPostCount === null) {
|
||||
|
|
Loading…
Reference in a new issue