Skip to content

Commit

Permalink
fix: check isFollowing and isLiking only when logged
Browse files Browse the repository at this point in the history
Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
  • Loading branch information
aofei committed Oct 18, 2024
1 parent 87f82b2 commit 1b497dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion spx-gui/src/components/community/user/FollowButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const props = defineProps<{
name: string
}>()
const followable = computed(() => props.name !== useUserStore().userInfo()?.name)
const userInfo = useUserStore().userInfo()
const followable = computed(() => userInfo != null && props.name !== userInfo.name)
const following = ref<boolean | null>(null)
watch(
Expand Down
8 changes: 7 additions & 1 deletion spx-gui/src/components/project/ProjectItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { universalUrlToWebUrl } from '@/models/common/cloud'
import { UIImg, UIDropdown, UIIcon, UIMenu, UIMenuItem } from '@/components/ui'
import UserAvatar from '@/components/community/user/UserAvatar.vue'
import { useRemoveProject } from '.'
import { useUserStore } from '@/stores'
/**
* Context (list) where the project item is used
Expand Down Expand Up @@ -100,7 +101,12 @@ const thumbnailUrl = useAsyncComputed(async () => {
return universalUrlToWebUrl(props.project.thumbnail)
})
const liking = useAsyncComputed(() => isLiking(props.project.owner, props.project.name))
const userStore = useUserStore()
const liking = useAsyncComputed(() => {
if (!userStore.isSignedIn()) return Promise.resolve(false)
else return isLiking(props.project.owner, props.project.name)
})
const likesTitle = computed(() => {
const count = humanizeExactCount(props.project.likeCount)
Expand Down

0 comments on commit 1b497dc

Please sign in to comment.