From 5492ec32bd81ecf33e48862d5c89399626a86708 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 21 Sep 2024 20:36:03 -0500 Subject: [PATCH] fix: external bag race condition --- app/react/components/dom/external.jsx | 6 +++++- app/react/components/ui.jsx | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/react/components/dom/external.jsx b/app/react/components/dom/external.jsx index 0b6fe2a..3755f7e 100644 --- a/app/react/components/dom/external.jsx +++ b/app/react/components/dom/external.jsx @@ -1,3 +1,5 @@ +import {memo} from 'react'; + import styles from './external.module.css'; import Grid from './grid.jsx'; @@ -5,7 +7,7 @@ import Grid from './grid.jsx'; /** * External inventory. */ -export default function External({ +function External({ isInventoryOpen, onActivate, slots, @@ -25,3 +27,5 @@ export default function External({ ); } + +export default memo(External); diff --git a/app/react/components/ui.jsx b/app/react/components/ui.jsx index 7e888df..cd598f6 100644 --- a/app/react/components/ui.jsx +++ b/app/react/components/ui.jsx @@ -383,6 +383,12 @@ function Ui({disconnected}) { payload: {type: 'swapSlots', value: [0, mainEntityRef.current, i + 11]}, }); }, [client, mainEntityRef]); + const externalInventoryOnActivate = useCallback((i) => { + client.send({ + type: 'Action', + payload: {type: 'swapSlots', value: [0, externalInventory, i]}, + }); + }, [client, externalInventory]); return (
{ - client.send({ - type: 'Action', - payload: {type: 'swapSlots', value: [0, externalInventory, i]}, - }); - }} + onActivate={externalInventoryOnActivate} slots={externalInventorySlots} /> )}