diff --git a/components/playlists/PlaylistView.vue b/components/playlists/PlaylistView.vue index 6737708..7d767ea 100644 --- a/components/playlists/PlaylistView.vue +++ b/components/playlists/PlaylistView.vue @@ -17,12 +17,21 @@ const session = useSupabaseSession(); const showModal = ref(false); +const intervalId = ref(); + onMounted(async () => { if (session.value) { await getPlaylists(); + intervalId.value = await setInterval(() => { + getPlaylists() + }, 5000); // 5 seconds } }); +onBeforeUnmount(() => { + clearInterval(intervalId.value); +}); + const emit = defineEmits(['chose-playlist']) /* Get all available playlists and get every category with corresponding playlist IDs*/ diff --git a/components/profile/Friendlist.vue b/components/profile/Friendlist.vue index 79b4d51..5a93a19 100644 --- a/components/profile/Friendlist.vue +++ b/components/profile/Friendlist.vue @@ -1,30 +1,26 @@ \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index 50254c8..b298f39 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -14,10 +14,19 @@ const curr_game = useState('current_game', () => null); const showModal = ref(false); +const intervalId = ref(); + onMounted(async () => { setLevelbar(70); await fetchUser(); await fetchGames(); + intervalId.value = await setInterval(() => { + fetchGames() + }, 15000); // 15 seconds +}); + +onBeforeUnmount(() => { + clearInterval(intervalId.value); }); function setLevelbar(newValue: number) {