fork/replay-manager-for-slippi
git clone https://git.julia.blue/fork/replay-manager-for-slippi
ac16564
2.3.6
1import React , { useEffect , useState } from 'react' ; 2import { 3AppBar , 4CircularProgress , 5IconButton , 6List , 7ListItem , 8ListItemText , 9Stack , 10Toolbar , 11Tooltip , 12Typography , 13} from '@mui/material' ; 14import { createRoot } from 'react-dom/client' ; 15import { Refresh } from '@mui/icons-material' ; 16import { RendererPool , RendererWave , Seed } from '../common/types' ; 17 18function SeedListItemContents ({ seed} :{ seed :Seed }) { 19let ret :any = '\xa0' ; 20if ( seed . entrant ) { 21ret = seed . entrant . participants 22. map (( participant ) => participant . displayName ) 23. join ( ' / ' ); 24} else if ( seed . placeholder ) { 25ret = < span style = {{ fontStyle :'italic' }}>{ seed . placeholder }</ span >; 26} 27return ret ; 28} 29 30function Pool ({ pool} :{ pool :RendererPool }) { 31return ( 32< Stack width = "200px" > 33< Typography variant = "caption" >{ pool . name }</ Typography > 34< List > 35{ pool . seeds . map (( seed ) => ( 36< ListItemText 37key = { seed . id } 38slotProps = {{ 39primary :{ 40style :{ 41overflowX :'hidden' , 42textOverflow :'ellipsis' , 43whiteSpace :'nowrap' , 44}, 45}, 46}} 47> 48< SeedListItemContents seed = { seed } /> 49</ ListItemText > 50))} 51</ List > 52</ Stack > 53); 54} 55 56function WaveEl ({ wave} :{ wave :RendererWave }) { 57return ( 58< ListItem 59style = {{ 60display :'flex' , 61flexDirection :'row' , 62flexWrap :'wrap' , 63alignItems :'start' , 64gap :'8px' , 65}} 66> 67{ wave . pools . map (( pool ) => ( 68< Pool key = { pool . id } pool = { pool } /> 69))} 70</ ListItem > 71); 72} 73 74function Entrants () { 75const [ waves , setWaves ] = useState < RendererWave []>([]); 76const [ gettingWaves , setGettingWaves ] = useState ( true ); 77 78useEffect (() => { 79( async () => { 80try { 81setWaves ( await window . electron . getPoolsByWave ()); 82} catch { 83// just catch 84} 85setGettingWaves ( false ); 86})(); 87}, []); 88 89return ( 90<> 91< AppBar position = "fixed" color = "inherit" > 92< Toolbar disableGutters style = {{ justifyContent :'space-between' }}> 93< Typography variant = "h5" marginLeft = "16px" > 94Seeds by Pool 95</ Typography > 96< Tooltip arrow title = "Refresh" > 97< IconButton 98disabled = { gettingWaves } 99onClick = { async () => { 100setGettingWaves ( true ); 101try { 102setWaves ( await window . electron . getPoolsByWave ()); 103} catch { 104// just catch 105} 106setGettingWaves ( false ); 107}} 108> 109< Refresh /> 110</ IconButton > 111</ Tooltip > 112</ Toolbar > 113</ AppBar > 114{ gettingWaves ?( 115< Stack 116width = "100%" 117height = "100%" 118alignItems = "center" 119justifyContent = "center" 120> 121< CircularProgress size = "24px" /> 122</ Stack > 123) :( 124< List disablePadding style = {{ marginTop :'64px' }}> 125{ waves . map (( wave ) => ( 126< WaveEl key = { wave . id } wave = { wave } /> 127))} 128</ List > 129)} 130</> 131); 132} 133 134const container = document . getElementById ( 'root' ) as HTMLElement ; 135const root = createRoot ( container ); 136root . render (< Entrants />);