Ignore:
Timestamp:
07/15/22 14:45:30 (2 years ago)
Author:
anastasovv <simon@…>
Branches:
main
Children:
55701f0
Parents:
1df3fde
Message:

Added complaints, managing credits, and lost connection screens

File:
1 edited

Legend:

Unmodified
Added
Removed
  • components/poker/PokerHeader.jsx

    r1df3fde r433e0c5  
    1010import { useDispatch, useSelector } from 'react-redux'
    1111
    12 import { setPlayer, setPokerGame, setSocket } from '../../redux/reducers/playerSlice'
     12import { setPlayer, setPokerGame } from '../../redux/reducers/playerSlice'
    1313import { setStyle } from '../../redux/reducers/styleSlice'
    1414
     
    3636                if (interval !== null) clearInterval(interval);
    3737
    38                 dispatch(setPlayer({
    39                     ...playerState.player,
    40                     displayName: res.data?.displayName,
    41                     session_id: res.data?.session_id,
    42                     credits: res.data?.credits,
    43                 }));
    44 
    45                 dispatch(setStyle({
    46                     ...styleState.style,
    47                     displayLoadingScreen: false,
    48                 }))
    49 
    5038                interval = setInterval(() => {
    5139                    axios.get(`/api/poker?action=update_state&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(newRes => {
     
    5644                                dispatch(setPlayer({
    5745                                    ...playerState.player,
     46                                    displayName: res.data?.displayName,
     47                                    session_id: res.data?.session_id,
    5848                                    credits: newRes.data?.pokerGame?.player?.credits,
    5949                                }))
    6050                            }
    6151                        }
     52
     53                        dispatch(setStyle({
     54                            ...styleState.style,
     55                            displayLoadingScreen: false,
     56                            notification: {
     57                                ...styleState.style.notification,
     58                                show: false,
     59                            },
     60                            lostConnectionInfo: {
     61                                show: false,
     62                                message: ''
     63                            }
     64                        }))
     65                    }).catch(error => {
     66                        dispatch(setStyle({
     67                            ...styleState.style,
     68                            displayLoadingScreen: false,
     69                            lostConnectionInfo: {
     70                                show: true,
     71                                message: 'Game will be played until the end upon server gets live. You cannot continue your game, but the money earned / lost will be updated.'
     72                            }
     73                        }))
    6274                    });
    63                 }, 2000);
     75                }, 1000);
    6476            }
    6577            else {
Note: See TracChangeset for help on using the changeset viewer.