Merge remote-tracking branch 'origin/jo-wip' into jo-wip

This commit is contained in:
PascalMarchesseault
2024-08-04 23:55:14 -04:00
5 changed files with 33 additions and 29 deletions

View File

@@ -1,13 +1,12 @@
<template>
<v-infinite-scroll :items="contents"
:onLoad="load">
:onLoad="fetchContents">
<template v-for="content in contents">
<ContentCard :content="content"
class="w-full p-2 my-2"
>
</ContentCard>
<content-card :content="content"
class="w-full p-2 my-2"
></content-card>
</template>
<template v-slot:empty>
@@ -20,14 +19,12 @@
</v-infinite-scroll>
<p class="bg-orange">test</p>
</template>
<script setup>
import {useClient} from '@/plugins/api.js';
import {ref} from 'vue';
import {ref, watch} from 'vue';
import ContentCard from "./ContentCard.vue";
const props = defineProps({
@@ -43,7 +40,23 @@ const page_size = 10
const errorMessage = ref()
let last_id = null
async function load({done}) {
const creatorIdWatcher = watch(
() => props.creatorId,
(newCreatorId) => {
if (newCreatorId) {
// Reset contents and last_id when the creatorId changes
contents.value = [];
last_id = null;
// Fetch contents for the new creator
fetchContents({
done: () => {
}
});
}
},
{immediate: true})
async function fetchContents({done}) {
try {
let uri = `/api/contents/creator/${props.creatorId}?page_size=${page_size}`
if (last_id !== null) uri = uri + `&last_id=${last_id}`

View File

@@ -2,6 +2,7 @@
<div v-if="creator && creator.id">
<creator-banner :creator="creator"></creator-banner>
<donation-popup :creator-id="creator.id"></donation-popup>
<div class="max-w-[1000px] mx-auto flex flex-row justify-center border-l-2 border-r-2 -mt-6 ">
@@ -43,32 +44,22 @@ const route = useRoute();
const creator = ref(null);
const loading = ref(true);
onBeforeMount(async () => {
setTimeout(() => {
loading.value = false;
}, 1500);
await fetchCreatorData(route.params.creator);
});
onBeforeMount(async () => await fetchCreatorData(route.params.creator))
watch(
() => route.params.creator,
async () => {
loading.value = true;
setTimeout(() => {
loading.value = false;
}, 1000);
await fetchCreatorData(route.params.creator);
}
);
async () => await fetchCreatorData(route.params.creator)
)
const fetchCreatorData = async (creatorAlias) => {
try {
loading.value = true
const response = await client.get(`/api/creators/@${creatorAlias}`)
creator.value = response.data;
console.log('loaded the following creator from api');
console.table(creator.value.id);
creator.value = response.data
} catch (error) {
console.error(`Error fetching content: ${error}`);
console.error(`Error fetching content: ${error}`)
} finally {
loading.value = false
}
}

View File

@@ -30,7 +30,7 @@
<v-btn variant="plain"> Guide pour les créateurs</v-btn>
</router-link>
<router-link to="/termsandconditions">
<v-btn variant="plain"> TermsAndConditions </v-btn>
<v-btn variant="plain">Termes et Conditions </v-btn>
</router-link>
<router-link to="/contentpolicy">
<v-btn variant="plain"> Politique de Contenu </v-btn>