diff --git a/pages/my/index.vue b/pages/my/index.vue index 7ed7f45..1471b8a 100644 --- a/pages/my/index.vue +++ b/pages/my/index.vue @@ -5,9 +5,7 @@ import type { World } from "~/models/World"; const supabase = useSupabaseClient() -const { data: res } = await useFetch("/api/worlds/query") - -const worlds = ref(res.value?.data as World[]) +const { data: worlds } = await useLazyFetch<{ data: World[] }>("/api/worlds/query") definePageMeta({ middleware: ["auth-guard"] @@ -36,8 +34,10 @@ let worldChannel: RealtimeChannel /** Handles world insertion realtime events */ function handleInsertedWorld(newWorld: World) { + if (!worlds.value?.data) return + try { - worlds.value.push(newWorld) + worlds.value?.data.push(newWorld) } catch (err) { console.log(err) } @@ -45,8 +45,10 @@ function handleInsertedWorld(newWorld: World) { /** Handles world deletion realtime events */ function handleDeletedWorld(id: number) { + if (!worlds.value?.data) return + try { - worlds.value.splice(worlds.value.findIndex(w => w.id === id)) + worlds.value.data.splice(worlds.value.data.findIndex(w => w.id === id)) } catch (err) { console.log(err) } @@ -68,7 +70,9 @@ onMounted(() => { break case "UPDATE": - worlds.value = (await $fetch("/api/worlds/query")).data as World[] + if (!worlds.value?.data) return + + worlds.value.data = (await $fetch("/api/worlds/query")).data as World[] break default: @@ -101,7 +105,7 @@ function hideDeleteModal() { - - diff --git a/pages/my/worlds/[id].vue b/pages/my/worlds/[id].vue index 992f05d..a19dd3b 100644 --- a/pages/my/worlds/[id].vue +++ b/pages/my/worlds/[id].vue @@ -208,29 +208,3 @@ function hideDeleteModal() { - - diff --git a/public/images/galaxy.svg b/public/images/galaxy.svg deleted file mode 100644 index 9f7e863..0000000 --- a/public/images/galaxy.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - diff --git a/public/images/planet.svg b/public/images/planet.svg deleted file mode 100644 index f632d3d..0000000 --- a/public/images/planet.svg +++ /dev/null @@ -1 +0,0 @@ -