Show bookmark heart to all users, redirect to login if not authenticated
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c62229c795
commit
ced192b65e
1 changed files with 6 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Heart } from 'lucide-vue-next'
|
import { Heart } from 'lucide-vue-next'
|
||||||
import { useAuth } from '@/composables/useAuthService'
|
import { useAuth } from '@/composables/useAuthService'
|
||||||
|
|
@ -15,6 +16,7 @@ const props = defineProps<{
|
||||||
kind?: number
|
kind?: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const { isAuthenticated } = useAuth()
|
const { isAuthenticated } = useAuth()
|
||||||
const { isBookmarked, toggleBookmark } = useBookmarks()
|
const { isBookmarked, toggleBookmark } = useBookmarks()
|
||||||
|
|
||||||
|
|
@ -22,13 +24,16 @@ const activityKind = computed(() => props.kind ?? NIP52_KINDS.CALENDAR_TIME_EVEN
|
||||||
const bookmarked = computed(() => isBookmarked(activityKind.value, props.pubkey, props.dTag))
|
const bookmarked = computed(() => isBookmarked(activityKind.value, props.pubkey, props.dTag))
|
||||||
|
|
||||||
function handleToggle() {
|
function handleToggle() {
|
||||||
|
if (!isAuthenticated.value) {
|
||||||
|
router.push('/login')
|
||||||
|
return
|
||||||
|
}
|
||||||
toggleBookmark(activityKind.value, props.pubkey, props.dTag)
|
toggleBookmark(activityKind.value, props.pubkey, props.dTag)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Button
|
<Button
|
||||||
v-if="isAuthenticated"
|
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
class="h-8 w-8"
|
class="h-8 w-8"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue