message2opponent works proposals

but does nothing in reality sicne no actual message is being included
in request
This commit is contained in:
djmil 2023-11-15 09:36:23 +01:00
parent 9c8e296684
commit cbc78dfcf1
2 changed files with 18 additions and 10 deletions

View File

@ -8,13 +8,17 @@ export default function Message2Opponent({ dispatchGames }) {
const [value, setValue] = useState(''); const [value, setValue] = useState('');
const syncTimeoutRef = useRef(null); const syncTimeoutRef = useRef(null);
if (syncTimeoutRef.current === null) { // <<--- Absorb external value if there is no scheduled sync if (syncTimeoutRef.current === null) { // <<--- Absorb external value ONLY if there is no scheduled sync
if (matchPath('/games/new', pathname)) { var externalValue = '';
if (value !== games.newGame.message2opponent)
setValue(games.newGame.message2opponent); if (matchPath('/games/new', pathname))
} else if (value !== '') { externalValue = games.newGame.message2opponent;
setValue(''); 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; syncTimeoutRef.current = null;
if (matchPath('/games/new', pathname)) if (matchPath('/games/new', pathname))
return dispatchGames({ type: 'nextNewGame', message2opponent }); dispatchGames({ type: 'nextNewGame', message2opponent });
else
console.warn('unknown path'); if (matchPath('/games/proposal', pathname))
dispatchGames({ type: 'nextProposal', message2opponent });
else
console.warn('unknown path');
} }
const update = (value) => { const update = (value) => {

View File

@ -12,6 +12,7 @@ const initialState = {
proposal: { proposal: {
selectedUUID: null, selectedUUID: null,
message2opponent: '',
}, },
// Network // Network