no chatting in the archives!
This commit is contained in:
parent
6343f70851
commit
392e7e9251
@ -8,15 +8,22 @@ export default function Message2Opponent({ dispatchGames }) {
|
||||
const [value, setValue] = useState('');
|
||||
const syncTimeoutRef = useRef(null);
|
||||
|
||||
if (matchPath('/games/archive', pathname))
|
||||
return; // Shhh.. no chatting in the archives!
|
||||
|
||||
if (matchPath('/games/proposal', pathname))
|
||||
return; // TODO: Enable GameProposal messages, as soon as it has been supported by the server side
|
||||
|
||||
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))
|
||||
else if (matchPath('/games/proposal', pathname))
|
||||
externalValue = games.proposal.message2opponent;
|
||||
|
||||
else if (matchPath('/games/active', pathname))
|
||||
externalValue = games.active.message2opponent;
|
||||
|
||||
if (value !== externalValue)
|
||||
setValue(externalValue);
|
||||
}
|
||||
@ -27,12 +34,15 @@ export default function Message2Opponent({ dispatchGames }) {
|
||||
syncTimeoutRef.current = null;
|
||||
|
||||
if (matchPath('/games/new', pathname))
|
||||
dispatchGames({ type: 'nextNewGame', message2opponent });
|
||||
else
|
||||
return dispatchGames({ type: 'nextNewGame', message2opponent });
|
||||
|
||||
if (matchPath('/games/proposal', pathname))
|
||||
dispatchGames({ type: 'nextProposal', message2opponent });
|
||||
else
|
||||
console.warn('unknown path');
|
||||
return dispatchGames({ type: 'nextProposal', message2opponent });
|
||||
|
||||
if (matchPath('/games/active', pathname))
|
||||
return dispatchGames({ type: 'nextActive', message2opponent });
|
||||
|
||||
console.warn('unknown path');
|
||||
}
|
||||
|
||||
const update = (value) => {
|
||||
|
@ -54,13 +54,13 @@ function reducer(state, action) {
|
||||
case 'nextActive':
|
||||
return {
|
||||
...state,
|
||||
proposal: nextState(state.proposal, action)
|
||||
active: nextState(state.active, action)
|
||||
};
|
||||
|
||||
case 'nextArchive':
|
||||
return {
|
||||
...state,
|
||||
proposal: nextState(state.proposal, action)
|
||||
archive: nextState(state.archive, action)
|
||||
};
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user