Changeset 3a783f2 for components/poker/PokerHeader.jsx
- Timestamp:
- 07/05/22 16:36:24 (2 years ago)
- Branches:
- main
- Children:
- 189cd8f
- Parents:
- b13f93b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
components/poker/PokerHeader.jsx
rb13f93b r3a783f2 23 23 const styleState = useSelector(state => state.style); 24 24 25 useEffect(() => async function(){25 useEffect(() => { 26 26 // display loading screen 27 27 dispatch(setStyle({ … … 30 30 })); 31 31 32 let interval = setInterval(() => { 33 axios.get(`/api/poker?action=update_state&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => { 34 if (res.data?.success) { 35 dispatch(setPokerGame(res.data?.pokerGame)) 36 } 37 }); 38 }, 3000); 32 let interval; 39 33 40 34 axios.get(`/api/poker?action=get_player_info_on_enter&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => { … … 51 45 displayLoadingScreen: false, 52 46 })) 47 48 interval = setInterval(() => { 49 axios.get(`/api/poker?action=update_state&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(newRes => { 50 if (newRes.data?.success) { 51 dispatch(setPokerGame(newRes.data?.pokerGame)) 52 53 if (newRes.data?.pokerGame?.player?.credits !== playerState.player.credits && newRes.data?.pokerGame?.player?.credits > 0) { 54 dispatch(setPlayer({ 55 ...playerState.player, 56 credits: newRes.data?.pokerGame?.player?.credits, 57 })) 58 } 59 } 60 }); 61 }, 2000); 53 62 } 54 63 else { … … 66 75 } 67 76 }); 68 69 return () => clearInterval(interval); 70 }, [playerState.pokerGame.player.table]) 77 }, []) 78 79 function leaveTable() { 80 axios.get(`/api/poker?action=leave_table&session_id=${localStorage.CAESSINO_SESSION_ID}`); 81 } 71 82 72 83 return ( 73 84 <header className="header"> 74 <Link href="/" passHref> 75 <h2> 76 <AiOutlineArrowLeft /> 77 </h2> 78 </Link> 85 <div style={{display: 'flex', alignItems: 'center'}}> 86 <Link href="/" passHref> 87 <h2> 88 <AiOutlineArrowLeft /> 89 </h2> 90 </Link> 91 { playerState.pokerGame.player.table.length > 0 && <button style={{marginBottom: '4px', marginLeft: '32px', fontSize: '16px'}} className="tertiaryButton" onClick={() => leaveTable()}>Leave Table</button> } 92 </div> 79 93 <nav> 80 94 <ul>
Note:
See TracChangeset
for help on using the changeset viewer.