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 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,8 +27,11 @@ export default function Message2Opponent({ dispatchGames }) {
syncTimeoutRef.current = null;
if (matchPath('/games/new', pathname))
return dispatchGames({ type: 'nextNewGame', message2opponent });
dispatchGames({ type: 'nextNewGame', message2opponent });
else
if (matchPath('/games/proposal', pathname))
dispatchGames({ type: 'nextProposal', message2opponent });
else
console.warn('unknown path');
}

View File

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