-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
When a user presses Shift + I, all buttons are cleared from their screen. When they press Shift + I again, all buttons become visible again for that user.
The Shift + I state is tracked by a single state shouldClearAllButtons in the global InSimContextProvider:
react-node-insim/src/lib/internals/InSimContext.tsx
Lines 41 to 64 in 7b2a50e
| const [shouldClearAllButtons, setShouldClearAllButtons] = useState(false); | |
| const [isConnected, setIsConnected] = useState(false); | |
| useEffect(() => { | |
| const bfnListener = (packet: IS_BFN) => { | |
| if (packet.SubT === ButtonFunction.BFN_USER_CLEAR) { | |
| log('User cleared all buttons'); | |
| setShouldClearAllButtons(true); | |
| return; | |
| } | |
| if (packet.SubT === ButtonFunction.BFN_REQUEST) { | |
| log('User requested to show all buttons'); | |
| setShouldClearAllButtons(false); | |
| return; | |
| } | |
| }; | |
| inSim.on(PacketType.ISP_BFN, bfnListener); | |
| return () => { | |
| inSim.off(PacketType.ISP_BFN, bfnListener); | |
| }; | |
| }, []); |
This means that if one player restores their buttons, not only their buttons are shown again, but everyone else's buttons get shown as well if they has been hidden before.
Proposal: Keep track of the UCIDs which have requested to clear all buttons and when buttons are requested to be shown again, only show buttons for that UCID.