From 593ca10720635c4b467bed42721b074e7f3ed45d Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Fri, 4 Aug 2023 10:29:40 +0200 Subject: [PATCH] cleanup --- client/src/components/level.tsx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/client/src/components/level.tsx b/client/src/components/level.tsx index a1c573b..0398cc4 100644 --- a/client/src/components/level.tsx +++ b/client/src/components/level.tsx @@ -47,13 +47,11 @@ function Level() { const params = useParams() const levelId = parseInt(params.levelId) const worldId = params.worldId - useLoadWorldFiles(worldId) return {levelId == 0 ? : } - } function ChatPanel({lastLevel}) { @@ -105,7 +103,6 @@ function ChatPanel({lastLevel}) { console.debug(`help: ${Array.from(tmp.values())}`) } - useEffect(() => { // TODO: For some reason this is always called twice console.debug('scroll chat') @@ -129,7 +126,6 @@ function ChatPanel({lastLevel}) { // // chatRef.current!.scrollTo(0,0) // }, [gameId, worldId, levelId]) - return
{level?.data?.introduction && @@ -196,6 +192,15 @@ function PlayableLevel() { const codeviewRef = useRef(null) const gameId = React.useContext(GameIdContext) const {worldId, levelId} = useContext(WorldLevelIdContext) + const {mobile} = React.useContext(MobileContext) + + const difficulty = useSelector(selectDifficulty(gameId)) + const initialCode = useAppSelector(selectCode(gameId, worldId, levelId)) + const initialSelections = useAppSelector(selectSelections(gameId, worldId, levelId)) + const inventory: Array = useSelector(selectInventory(gameId)) + + const gameInfo = useGetGameInfoQuery({game: gameId}) + const level = useLoadLevelQuery({game: gameId, world: worldId, level: levelId}) // The state variables for the `ProofContext` const [proof, setProof] = useState>([]) @@ -204,18 +209,11 @@ function PlayableLevel() { const [deletedChat, setDeletedChat] = useState>([]) // A set of row numbers where help is displayed const [showHelp, setShowHelp] = useState>(new Set()) - const initialCode = useAppSelector(selectCode(gameId, worldId, levelId)) - const initialSelections = useAppSelector(selectSelections(gameId, worldId, levelId)) - /** Only for mobile layout */ + // Only for mobile layout const [pageNumber, setPageNumber] = useState(0) - const {mobile} = React.useContext(MobileContext) const [commandLineMode, setCommandLineMode] = useState(true) const [commandLineInput, setCommandLineInput] = useState("") - const difficulty = useSelector(selectDifficulty(gameId)) - const inventory: Array = useSelector(selectInventory(gameId)) - const gameInfo = useGetGameInfoQuery({game: gameId}) const lastLevel = levelId >= gameInfo.data?.worldSize[worldId] - const level = useLoadLevelQuery({game: gameId, world: worldId, level: levelId}) const dispatch = useAppDispatch() // impressum pop-up