diff --git a/webapp/src/container/games/Message2Opponent.jsx b/webapp/src/container/games/Message2Opponent.jsx index 21dca32..d0acc76 100644 --- a/webapp/src/container/games/Message2Opponent.jsx +++ b/webapp/src/container/games/Message2Opponent.jsx @@ -8,13 +8,17 @@ export default function Message2Opponent({ dispatchGames }) { const [value, setValue] = useState(''); const syncTimeoutRef = useRef(null); - if (syncTimeoutRef.current === null) { // <<--- Absorb external value if there is no scheduled sync - if (matchPath('/games/new', pathname)) { - if (value !== games.newGame.message2opponent) - setValue(games.newGame.message2opponent); - } else if (value !== '') { - setValue(''); - } + if (syncTimeoutRef.current === null) { // <<--- Absorb external value ONLY if there is no scheduled sync + var externalValue = ''; + + if (matchPath('/games/new', pathname)) + externalValue = games.newGame.message2opponent; + else + if (matchPath('/games/proposal', pathname)) + externalValue = games.proposal.message2opponent; + + if (value !== externalValue) + setValue(externalValue); } /* --- */ @@ -23,9 +27,12 @@ export default function Message2Opponent({ dispatchGames }) { syncTimeoutRef.current = null; if (matchPath('/games/new', pathname)) - return dispatchGames({ type: 'nextNewGame', message2opponent }); - - console.warn('unknown path'); + dispatchGames({ type: 'nextNewGame', message2opponent }); + else + if (matchPath('/games/proposal', pathname)) + dispatchGames({ type: 'nextProposal', message2opponent }); + else + console.warn('unknown path'); } const update = (value) => { diff --git a/webapp/src/reducer/games.js b/webapp/src/reducer/games.js index 50a1add..4b083c5 100644 --- a/webapp/src/reducer/games.js +++ b/webapp/src/reducer/games.js @@ -12,6 +12,7 @@ const initialState = { proposal: { selectedUUID: null, + message2opponent: '', }, // Network