Version 1.0.0 - Finalisation du composant Servers

This commit is contained in:
2025-07-25 22:56:25 +02:00
parent e3d7a911f4
commit 4fdd4aad61
15 changed files with 1632 additions and 58 deletions

View File

@@ -21,8 +21,8 @@ import { watch } from 'vue';
import { useRouter } from 'vue-router';
import { useGlobalStore } from '@/stores/globalStore';
import { useUserStore } from '@/stores/userStore';
import { IOListener } from '@/utils/IORequest';
import { onMounted } from 'vue';
import { IOListener, IORequest } from '@/utils/IORequest';
import { onMounted, ref } from 'vue';
const props = defineProps({
guildId: {
@@ -40,9 +40,10 @@ if (!guildId) {
const globalStore = useGlobalStore();
const userStore = useUserStore();
const router = useRouter();
const alreadyLoaded = ref(false);
watch(() => globalStore.isLoading, (value) => {
if(!value) {
watch(() => globalStore.isLoading, (value, oldValue) => {
if(!value && oldValue != value) {
loadInteface();
}
})
@@ -53,19 +54,42 @@ onMounted(() => {
}
});
watch(() => userStore.userInfo, (newValue, oldValue) => {
if(userStore.userInfo) {
checkGuildAvailability();
}
}, { immediate: true });
function loadInteface() {
if(alreadyLoaded.value) return;
console.log("Loading interface")
console.log("Guild ID:", guildId);
checkGuildAvailability();
IORequest("/USERS/LIST", (data) => {
console.log("User list received:", data);
})
alreadyLoaded.value = true;
}
function checkGuildAvailability() {
console.log("Checking guild availability for ID:", guildId);
if(userStore.userInfo.guilds.filter(guild => guild.id === guildId).length === 0) {
globalStore.setLastGuild(null);
console.warn("Guild not found, redirecting to servers list.");
router.push('/servers');
} else {
globalStore.setLastGuild(guildId);
IORequest("/GUILD/JOIN", (response) => {
if(response === true) {
console.log("Successfully joined guild:", guildId);
} else {
console.error("Failed to join guild:", response);
globalStore.setLastGuild(null);
router.push('/servers');
}
}, guildId);
}
}