Skip to content

Commit be75bee

Browse files
fix: orientation bug + clean up code
1 parent ff0d907 commit be75bee

4 files changed

Lines changed: 10 additions & 18 deletions

File tree

src/components/Training/Feedback.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,6 @@ export const Feedback: React.FC<Props> = ({
8383
Try Again
8484
</button>
8585
)}
86-
{status !== 'correct' && status !== 'incorrect' && (
87-
<button
88-
onClick={() => {
89-
controller.reset()
90-
if (status !== 'success' && status !== 'forfeit') {
91-
setStatus('default')
92-
}
93-
}}
94-
disabled={status == 'loading' || status == 'default'}
95-
className="flex w-full justify-center rounded-sm bg-engine-3 py-1.5 text-sm font-medium text-primary transition duration-300 hover:bg-engine-4 disabled:bg-backdrop disabled:text-secondary"
96-
>
97-
Reset
98-
</button>
99-
)}
10086
{status !== 'forfeit' && status !== 'correct' && (
10187
<button
10288
onClick={setAndGiveUp}

src/hooks/useAnalysisController/useAnalysisController.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ import { useEngineAnalysis } from './useEngineAnalysis'
1414
import { useMoveRecommendations } from './useMoveRecommendations'
1515
import { useBoardDescription } from './useBoardDescription'
1616

17-
export const useAnalysisController = (game: AnalyzedGame) => {
18-
const controller = useTreeController(game.tree)
17+
export const useAnalysisController = (
18+
game: AnalyzedGame,
19+
initialOrientation?: 'white' | 'black',
20+
) => {
21+
const controller = useTreeController(game.tree, initialOrientation)
1922

2023
const [analysisState, setAnalysisState] = useState(0)
2124
const inProgressAnalyses = useMemo(() => new Set<string>(), [])

src/pages/analysis/[...id].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ import { useRouter } from 'next/router'
4646
import type { Key } from 'chessground/types'
4747
import { Chess, PieceSymbol } from 'chess.ts'
4848
import { AnimatePresence } from 'framer-motion'
49+
import { useAnalysisController } from 'src/hooks'
4950
import type { DrawBrushes, DrawShape } from 'chessground/draw'
50-
import { useAnalysisController, useLocalStorage } from 'src/hooks'
5151
import { ConfigurableScreens } from 'src/components/Analysis/ConfigurableScreens'
5252

5353
const MAIA_MODELS = [

src/pages/train.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ const Train: React.FC<Props> = ({
244244
return convertTrainingGameToAnalyzedGame(trainingGame)
245245
}, [trainingGame])
246246

247-
const analysisController = useAnalysisController(analyzedGame)
247+
const analysisController = useAnalysisController(
248+
analyzedGame,
249+
controller.orientation,
250+
)
248251

249252
const { width } = useContext(WindowSizeContext)
250253
const isMobile = useMemo(() => width > 0 && width <= 670, [width])

0 commit comments

Comments
 (0)