diff options
| author | 2026-03-30 16:49:08 +0800 | |
|---|---|---|
| committer | 2026-03-30 16:49:08 +0800 | |
| commit | 878d66f9add4e4026a26ae2fa2a1226b5259154d (patch) | |
| tree | af78680c8d4f357843ab336bdac6e56a622de3c7 /packages/ui/src/components/bottom-bar.tsx | |
| parent | f8b4bcb3bdc8f11323103081ef8c05b06159d684 (diff) | |
| parent | c4dc0676d794bca2613be282867d369328ebf073 (diff) | |
| download | DropOut-878d66f9add4e4026a26ae2fa2a1226b5259154d.tar.gz DropOut-878d66f9add4e4026a26ae2fa2a1226b5259154d.zip | |
Merge branch 'main' of https://github.com/HydroRoll-Team/DropOut
Diffstat (limited to 'packages/ui/src/components/bottom-bar.tsx')
| -rw-r--r-- | packages/ui/src/components/bottom-bar.tsx | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/packages/ui/src/components/bottom-bar.tsx b/packages/ui/src/components/bottom-bar.tsx index 8f70985..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,27 +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?.id, activeInstance?.versionId, selectedVersion, setSelectedVersion]); + const [showLoginModal, setShowLoginModal] = useState(false); const handleInstanceChange = useCallback( async (instanceId: string) => { @@ -47,7 +37,9 @@ export function BottomBar() { return; } - const nextInstance = instances.find((instance) => instance.id === instanceId); + const nextInstance = instances.find( + (instance) => instance.id === instanceId, + ); if (!nextInstance) { return; } @@ -68,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 () => { |