Skip to content

Commit

Permalink
Fix add to collections
Browse files Browse the repository at this point in the history
  • Loading branch information
minghao.yang committed Nov 6, 2024
1 parent 669beeb commit 9c1b6f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions frontend/src/components/collections/AddToCollections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,27 @@
</div>
</template>
<script setup>
import { ref, watch } from 'vue'
import { ref, watch, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { useI18n } from 'vue-i18n'
import useFetchApi from '../../packs/useFetchApi';
import useUserStore from '../../stores/UserStore.js'
import { useCookies } from 'vue3-cookies'
const userStore = useUserStore()
const { t } = useI18n()
const { cookies } = useCookies()
const props = defineProps({
repoId: String,
userName: String
repoId: String
})
const currentUser = ref(cookies.get('current_user'))
const dialogVisible = ref(false)
const collectionsList = ref([])
const collectionsIdsInput = ref('')
const isLogged =ref(false)
const fetchCollectionsList = async () => {
const url = `/user/${props.userName}/collections`
const url = `/user/${currentUser.value}/collections`
const { data, error } = await useFetchApi(url).json()
const json = data.value
if (json) {
Expand Down Expand Up @@ -150,8 +152,10 @@
isLogged.value = userStore.isLoggedIn
})
watch(() => props.userName, () => {
fetchCollectionsList()
onMounted(() => {
if(currentUser.value){
fetchCollectionsList()
}
})
</script>
<style scoped>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/shared/RepoClone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div
class="flex flex-wrap items-center gap-4 md:relative md:pl-5 md:pb-4 z-10"
>
<AddToCollections v-if="showAddToCollections" :repoId="repo.repository_id" :userName="userName" />
<AddToCollections v-if="showAddToCollections" :repoId="repo.repository_id" />
<!-- multi-source sync button -->
<el-button
v-if="showSyncButton"
Expand Down

0 comments on commit 9c1b6f9

Please sign in to comment.