@@ -242,23 +242,7 @@ const Analysis: React.FC<Props> = ({
242242 const toastId = useRef < string > ( null )
243243 const [ currentSquare , setCurrentSquare ] = useState < Key | null > ( null )
244244
245- const {
246- maiaStatus,
247- downloadMaia,
248- maiaProgress,
249- controller,
250- move,
251- moves,
252- currentMaiaModel,
253- setCurrentMaiaModel,
254- colorSanMapping,
255- moveEvaluation,
256- movesByRating,
257- moveRecommendations,
258- moveMap,
259- blunderMeter,
260- boardDescription,
261- } = useAnalysisController ( analyzedGame )
245+ const controller = useAnalysisController ( analyzedGame )
262246
263247 useEffect ( ( ) => {
264248 controller . setCurrentNode ( analyzedGame . tree ?. getRoot ( ) )
@@ -275,9 +259,9 @@ const Analysis: React.FC<Props> = ({
275259 } , [ ] )
276260
277261 useEffect ( ( ) => {
278- if ( maiaStatus === 'loading' && ! toastId . current ) {
262+ if ( controller . maiaStatus === 'loading' && ! toastId . current ) {
279263 toastId . current = toast . loading ( 'Loading Maia Model...' )
280- } else if ( maiaStatus === 'ready' ) {
264+ } else if ( controller . maiaStatus === 'ready' ) {
281265 if ( toastId . current ) {
282266 toast . success ( 'Loaded Maia! Analysis is ready' , {
283267 id : toastId . current ,
@@ -286,7 +270,7 @@ const Analysis: React.FC<Props> = ({
286270 toast . success ( 'Loaded Maia! Analysis is ready' )
287271 }
288272 }
289- } , [ maiaStatus ] )
273+ } , [ controller . maiaStatus ] )
290274
291275 const launchContinue = useCallback ( ( ) => {
292276 const fen = controller . currentNode ?. fen as string
@@ -298,8 +282,8 @@ const Analysis: React.FC<Props> = ({
298282 useEffect ( ( ) => {
299283 const arr = [ ]
300284
301- if ( moveEvaluation ?. maia ) {
302- const maia = Object . entries ( moveEvaluation ?. maia ?. policy ) [ 0 ]
285+ if ( controller . moveEvaluation ?. maia ) {
286+ const maia = Object . entries ( controller . moveEvaluation ?. maia ?. policy ) [ 0 ]
303287 if ( maia ) {
304288 arr . push ( {
305289 brush : 'red' ,
@@ -309,8 +293,10 @@ const Analysis: React.FC<Props> = ({
309293 }
310294 }
311295
312- if ( moveEvaluation ?. stockfish ) {
313- const stockfish = Object . entries ( moveEvaluation ?. stockfish . cp_vec ) [ 0 ]
296+ if ( controller . moveEvaluation ?. stockfish ) {
297+ const stockfish = Object . entries (
298+ controller . moveEvaluation ?. stockfish . cp_vec ,
299+ ) [ 0 ]
314300 if ( stockfish ) {
315301 arr . push ( {
316302 brush : 'blue' ,
@@ -322,7 +308,11 @@ const Analysis: React.FC<Props> = ({
322308 }
323309
324310 setArrows ( arr )
325- } , [ moveEvaluation , controller . currentNode , controller . orientation ] )
311+ } , [
312+ controller . moveEvaluation ,
313+ controller . currentNode ,
314+ controller . orientation ,
315+ ] )
326316
327317 const hover = ( move ?: string ) => {
328318 if ( move ) {
@@ -366,7 +356,7 @@ const Analysis: React.FC<Props> = ({
366356 newFen ,
367357 moveString ,
368358 san ,
369- currentMaiaModel ,
359+ controller . currentMaiaModel ,
370360 )
371361 controller . goToNode ( newVariation )
372362 }
@@ -537,7 +527,7 @@ const Analysis: React.FC<Props> = ({
537527 < div className = "relative flex aspect-square w-[45vh] 2xl:w-[55vh]" >
538528 < GameBoard
539529 game = { analyzedGame }
540- moves = { moves }
530+ moves = { controller . moves }
541531 setCurrentSquare = { setCurrentSquare }
542532 shapes = { hoverArrow ? [ ...arrows , hoverArrow ] : [ ...arrows ] }
543533 currentNode = { controller . currentNode as GameNode }
@@ -562,8 +552,8 @@ const Analysis: React.FC<Props> = ({
562552 />
563553 </ div >
564554 < ConfigurableScreens
565- currentMaiaModel = { currentMaiaModel }
566- setCurrentMaiaModel = { setCurrentMaiaModel }
555+ currentMaiaModel = { controller . currentMaiaModel }
556+ setCurrentMaiaModel = { controller . setCurrentMaiaModel }
567557 launchContinue = { launchContinue }
568558 MAIA_MODELS = { MAIA_MODELS }
569559 game = { analyzedGame }
@@ -578,32 +568,32 @@ const Analysis: React.FC<Props> = ({
578568 < Highlight
579569 hover = { hover }
580570 makeMove = { makeMove }
581- currentMaiaModel = { currentMaiaModel }
582- recommendations = { moveRecommendations }
571+ currentMaiaModel = { controller . currentMaiaModel }
572+ recommendations = { controller . moveRecommendations }
583573 moveEvaluation = {
584- moveEvaluation as {
574+ controller . moveEvaluation as {
585575 maia ?: MaiaEvaluation
586576 stockfish ?: StockfishEvaluation
587577 }
588578 }
589- movesByRating = { movesByRating }
590- colorSanMapping = { colorSanMapping }
591- boardDescription = { boardDescription }
579+ movesByRating = { controller . movesByRating }
580+ colorSanMapping = { controller . colorSanMapping }
581+ boardDescription = { controller . boardDescription }
592582 />
593583 </ div >
594584 < div className = "flex h-[calc((55vh+4.5rem)/2)] flex-row gap-2" >
595585 < div className = "flex h-full w-full flex-col" >
596586 < MoveMap
597- moveMap = { moveMap }
598- colorSanMapping = { colorSanMapping }
587+ moveMap = { controller . moveMap }
588+ colorSanMapping = { controller . colorSanMapping }
599589 setHoverArrow = { setHoverArrow }
600590 />
601591 </ div >
602592 < BlunderMeter
603593 hover = { hover }
604594 makeMove = { makeMove }
605- data = { blunderMeter }
606- colorSanMapping = { colorSanMapping }
595+ data = { controller . blunderMeter }
596+ colorSanMapping = { controller . colorSanMapping }
607597 />
608598 </ div >
609599 </ div >
@@ -667,8 +657,8 @@ const Analysis: React.FC<Props> = ({
667657 title = "Analysis"
668658 icon = "bar_chart"
669659 type = "analysis"
670- currentMaiaModel = { currentMaiaModel }
671- setCurrentMaiaModel = { setCurrentMaiaModel }
660+ currentMaiaModel = { controller . currentMaiaModel }
661+ setCurrentMaiaModel = { controller . setCurrentMaiaModel }
672662 MAIA_MODELS = { MAIA_MODELS }
673663 onGameListClick = { ( ) => setShowGameListMobile ( true ) }
674664 showGameListButton = { true }
@@ -678,7 +668,7 @@ const Analysis: React.FC<Props> = ({
678668 < div className = "relative flex h-[100vw] w-screen" >
679669 < GameBoard
680670 game = { analyzedGame }
681- moves = { moves }
671+ moves = { controller . moves }
682672 setCurrentSquare = { setCurrentSquare }
683673 shapes = { hoverArrow ? [ ...arrows , hoverArrow ] : [ ...arrows ] }
684674 currentNode = { controller . currentNode as GameNode }
@@ -712,33 +702,33 @@ const Analysis: React.FC<Props> = ({
712702 < BlunderMeter
713703 hover = { hover }
714704 makeMove = { makeMove }
715- data = { blunderMeter }
716- colorSanMapping = { colorSanMapping }
705+ data = { controller . blunderMeter }
706+ colorSanMapping = { controller . colorSanMapping }
717707 />
718708 < Highlight
719709 hover = { hover }
720710 makeMove = { makeMove }
721- currentMaiaModel = { currentMaiaModel }
722- recommendations = { moveRecommendations }
711+ currentMaiaModel = { controller . currentMaiaModel }
712+ recommendations = { controller . moveRecommendations }
723713 moveEvaluation = {
724- moveEvaluation as {
714+ controller . moveEvaluation as {
725715 maia ?: MaiaEvaluation
726716 stockfish ?: StockfishEvaluation
727717 }
728718 }
729- movesByRating = { movesByRating }
730- colorSanMapping = { colorSanMapping }
731- boardDescription = { boardDescription }
719+ movesByRating = { controller . movesByRating }
720+ colorSanMapping = { controller . colorSanMapping }
721+ boardDescription = { controller . boardDescription }
732722 />
733723 < MoveMap
734- moveMap = { moveMap }
735- colorSanMapping = { colorSanMapping }
724+ moveMap = { controller . moveMap }
725+ colorSanMapping = { controller . colorSanMapping }
736726 setHoverArrow = { setHoverArrow }
737727 />
738728 </ div >
739729 < ConfigurableScreens
740- currentMaiaModel = { currentMaiaModel }
741- setCurrentMaiaModel = { setCurrentMaiaModel }
730+ currentMaiaModel = { controller . currentMaiaModel }
731+ setCurrentMaiaModel = { controller . setCurrentMaiaModel }
742732 launchContinue = { launchContinue }
743733 MAIA_MODELS = { MAIA_MODELS }
744734 game = { analyzedGame }
@@ -766,11 +756,15 @@ const Analysis: React.FC<Props> = ({
766756 />
767757 </ Head >
768758 < AnimatePresence >
769- { maiaStatus === 'no-cache' || maiaStatus === 'downloading' ? (
770- < DownloadModelModal progress = { maiaProgress } download = { downloadMaia } />
759+ { controller . maiaStatus === 'no-cache' ||
760+ controller . maiaStatus === 'downloading' ? (
761+ < DownloadModelModal
762+ progress = { controller . maiaProgress }
763+ download = { controller . downloadMaia }
764+ />
771765 ) : null }
772766 </ AnimatePresence >
773- < TreeControllerContext . Provider value = { { ... controller } } >
767+ < TreeControllerContext . Provider value = { controller } >
774768 { analyzedGame && ( isMobile ? mobileLayout : desktopLayout ) }
775769 </ TreeControllerContext . Provider >
776770 </ >
0 commit comments