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;
|
content: string;
|
||||||
in_reply_to_id: string | null;
|
in_reply_to_id: string | null;
|
||||||
reblog: Post | null;
|
reblog: Post | null;
|
||||||
|
visibility: "public" | "direct";
|
||||||
replies_count: number;
|
replies_count: number;
|
||||||
favourites_count: number;
|
favourites_count: number;
|
||||||
reblogs_count: number;
|
reblogs_count: number;
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
<img :src="require('@/assets/tabler/arrow-forward.svg')">
|
<img :src="require('@/assets/tabler/arrow-forward.svg')">
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
v-if="canRepost()"
|
||||||
class="icon"
|
class="icon"
|
||||||
:class="{ 'highlighted': post.reblogged }"
|
:class="{ 'highlighted': post.reblogged }"
|
||||||
title="Repost"
|
title="Repost"
|
||||||
|
@ -73,6 +74,7 @@
|
||||||
<span>{{ post.reblogs_count }}</span>
|
<span>{{ post.reblogs_count }}</span>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
v-if="canLike()"
|
||||||
class="icon"
|
class="icon"
|
||||||
:class="{ 'highlighted': post.favourited }"
|
:class="{ 'highlighted': post.favourited }"
|
||||||
title="Like"
|
title="Like"
|
||||||
|
@ -267,6 +269,10 @@ export default class PostComponent extends Vue {
|
||||||
this.$emit("comment-created", post)
|
this.$emit("comment-created", post)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canRepost(): boolean {
|
||||||
|
return this.store.currentUser !== null && this.post.visibility === "public"
|
||||||
|
}
|
||||||
|
|
||||||
async toggleRepost() {
|
async toggleRepost() {
|
||||||
if (!this.store.currentUser) {
|
if (!this.store.currentUser) {
|
||||||
return
|
return
|
||||||
|
@ -287,6 +293,10 @@ export default class PostComponent extends Vue {
|
||||||
this.post.reblogged = post.reblogged
|
this.post.reblogged = post.reblogged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canLike(): boolean {
|
||||||
|
return this.store.currentUser !== null
|
||||||
|
}
|
||||||
|
|
||||||
async toggleLike() {
|
async toggleLike() {
|
||||||
if (!this.store.currentUser) {
|
if (!this.store.currentUser) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -27,7 +27,7 @@ const props = defineProps<{
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits<{(event: "load-next-page", maxId: string): void}>()
|
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) => {
|
watch(() => props.posts.length, (postCount) => {
|
||||||
if (initialPostCount === null) {
|
if (initialPostCount === null) {
|
||||||
|
|
Loading…
Reference in a new issue