diff options
| author | 2026-03-30 17:28:40 +0800 | |
|---|---|---|
| committer | 2026-03-30 17:28:40 +0800 | |
| commit | 0c689afe68792fafca67746b9ece2a06760c6069 (patch) | |
| tree | 8d0feac4fec8c8ac06994f28949915d348eb3cc9 /packages/ui/src/components/bottom-bar.tsx | |
| parent | 382dfc68f1ecb09f277f82b0b2e0b466e1c79d06 (diff) | |
| parent | c4dc0676d794bca2613be282867d369328ebf073 (diff) | |
| download | DropOut-0c689afe68792fafca67746b9ece2a06760c6069.tar.gz DropOut-0c689afe68792fafca67746b9ece2a06760c6069.zip | |
Merge branch 'main' of https://github.com/HydroRoll-Team/DropOut into chore/docs
Diffstat (limited to 'packages/ui/src/components/bottom-bar.tsx')
| -rw-r--r-- | packages/ui/src/components/bottom-bar.tsx | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/packages/ui/src/components/bottom-bar.tsx b/packages/ui/src/components/bottom-bar.tsx index 2746e00..f73ace4 100644 --- a/packages/ui/src/components/bottom-bar.tsx +++ b/packages/ui/src/components/bottom-bar.tsx @@ -1,10 +1,10 @@ import { Play, User, XIcon } from "lucide-react"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useState } from "react"; import { toast } from "sonner"; import { cn } from "@/lib/utils"; import { useAuthStore } from "@/models/auth"; +import { useGameStore } from "@/models/game"; import { useInstanceStore } from "@/models/instance"; -import { useGameStore } from "@/stores/game-store"; import { LoginModal } from "./login-modal"; import { Button } from "./ui/button"; import { @@ -19,31 +19,17 @@ import { Spinner } from "./ui/spinner"; export function BottomBar() { const account = useAuthStore((state) => state.account); - const instances = useInstanceStore((state) => state.instances); - const activeInstance = useInstanceStore((state) => state.activeInstance); - const setActiveInstance = useInstanceStore( - (state) => state.setActiveInstance, - ); - const selectedVersion = useGameStore((state) => state.selectedVersion); - const setSelectedVersion = useGameStore((state) => state.setSelectedVersion); - const startGame = useGameStore((state) => state.startGame); - const stopGame = useGameStore((state) => state.stopGame); - const runningInstanceId = useGameStore((state) => state.runningInstanceId); - const launchingInstanceId = useGameStore( - (state) => state.launchingInstanceId, - ); - const stoppingInstanceId = useGameStore((state) => state.stoppingInstanceId); - - const [showLoginModal, setShowLoginModal] = useState(false); - useEffect(() => { - const nextVersion = activeInstance?.versionId ?? ""; - if (selectedVersion === nextVersion) { - return; - } + const { instances, activeInstance, setActiveInstance } = useInstanceStore(); + const { + runningInstanceId, + launchingInstanceId, + stoppingInstanceId, + startGame, + stopGame, + } = useGameStore(); - setSelectedVersion(nextVersion); - }, [activeInstance?.versionId, selectedVersion, setSelectedVersion]); + const [showLoginModal, setShowLoginModal] = useState(false); const handleInstanceChange = useCallback( async (instanceId: string) => { @@ -74,13 +60,7 @@ export function BottomBar() { return; } - await startGame( - account, - () => setShowLoginModal(true), - activeInstance.id, - selectedVersion || activeInstance.versionId, - () => undefined, - ); + await startGame(activeInstance.id, activeInstance.versionId ?? ""); }; const handleStopGame = async () => { |