Skip to content

Commit 7eab985

Browse files
authored
feature: a visitor who is not signed in no longer downloads the signed-in toast, voice and lobby code (#873)
1 parent 6516e48 commit 7eab985

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎layouts/components/TopNav.vue‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import { defineAsyncComponent } from "vue";
23
import {
34
NavigationMenu,
45
NavigationMenuContent,
@@ -21,7 +22,6 @@ import PlayerDisplay from "~/components/PlayerDisplay.vue";
2122
import PlayerPendingImports from "~/components/PlayerPendingImports.vue";
2223
import { useAuthStore } from "~/stores/AuthStore";
2324
import Logout from "./Logout.vue";
24-
import MatchLobbies from "./MatchLobbies.vue";
2525
import DraftRoomNav from "./DraftRoomNav.vue";
2626
import SystemStatus from "./SystemStatus.vue";
2727
import { useSidebar } from "~/components/ui/sidebar/utils";
@@ -180,6 +180,11 @@ const loginButtonClasses =
180180
"group relative inline-flex items-center gap-[0.45rem] rounded-md border border-[hsl(var(--tac-amber)/0.55)] bg-[linear-gradient(180deg,hsl(var(--tac-amber)/0.14)_0%,hsl(var(--tac-amber)/0.06)_100%)] px-[0.8rem] py-[0.45rem] font-sans text-[0.68rem] font-bold uppercase tracking-[0.16em] text-topnav-foreground transition-[background-color,color,transform] duration-150 hover:bg-[linear-gradient(180deg,hsl(var(--tac-amber)/0.28)_0%,hsl(var(--tac-amber)/0.14)_100%)] active:translate-y-px sm:px-3 sm:py-[0.35rem] sm:text-[0.65rem] sm:tracking-[0.18em]";
181181
const loginArrowClasses =
182182
"font-sans text-[hsl(var(--tac-amber))] transition-transform duration-150 group-hover:translate-x-[3px]";
183+
184+
// Signed-in only (it sits under `v-if="me"`), and it carries the lobby, quick
185+
// queue and player-search UI with it: a visitor who is not signed in never
186+
// downloads any of that.
187+
const MatchLobbies = defineAsyncComponent(() => import("./MatchLobbies.vue"));
183188
</script>
184189

185190
<template>

‎layouts/default.vue‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ useChatBlocks();
8383
const route = useRoute();
8484
const authStore = useAuthStore();
8585
86+
// TopNav loads MatchLobbies lazily, and the root Suspense holds the pre-loader
87+
// until it arrives. Asking for it here, while TopNav's own chunk is still on
88+
// its way, keeps a signed-in boot from paying for the two one after the other.
89+
if (authStore.me) {
90+
void import("~/layouts/components/MatchLobbies.vue");
91+
}
92+
8693
const showLeftNav = computed(() => {
8794
return authStore.isRoleAbove(e_player_roles_enum.match_organizer);
8895
});
@@ -184,7 +191,7 @@ provide("containContent", containContent);
184191

185192
<EnablePushPrompt v-if="authStore.me" />
186193

187-
<ActionToasts />
194+
<ActionToasts v-if="authStore.me" />
188195
</template>
189196

190197
<script lang="ts">

0 commit comments

Comments
 (0)