Skip to content

Commit

Permalink
Fix sync issues and click event for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmi committed Feb 18, 2024
1 parent a08be7c commit 6e03f3f
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 178 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"react-icons": "^4.8.0",
"react-query": "^3.39.3",
"react-router-dom": "^6.8.0",
"react-sync-board": "^1.2.3",
"react-sync-board": "^1.2.4",
"react-toastify": "^6.1.0",
"recoil": "^0.7.4",
"socket.io-client": "^4.1.2",
Expand Down
19 changes: 13 additions & 6 deletions src/gameComponents/AdvancedImage/AdvancedImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,24 @@ const AdvancedImage = ({

const onPlaceItem = React.useCallback(
(itemIds) => {
setState((item) => ({
...item,
linkedItems: getHeldItems({
setState((item) => {
const newLinkedItems = getHeldItems({
element: wrapperRef.current,
currentItemId,
linkedItemIds: item.linkedItems,
currentLinkedItemIds: item.linkedItems,
itemList: getItemList(),
itemIds,
shouldHoldItems: item.holdItems,
}),
}));
});

if (item.linkedItems !== newLinkedItems) {
return {
linkedItems: newLinkedItems,
};
}

return {};
}, true);
},
[currentItemId, getItemList, setState]
);
Expand Down
19 changes: 13 additions & 6 deletions src/gameComponents/CheckerBoard/CheckerBoard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,24 @@ const CheckerBoard = ({

const onPlaceItem = React.useCallback(
(itemIds) => {
setState((item) => ({
...item,
linkedItems: getHeldItems({
setState((item) => {
const newLinkedItems = getHeldItems({
element: wrapperRef.current,
currentItemId,
linkedItemIds: item.linkedItems,
currentLinkedItemIds: item.linkedItems,
itemList: getItemList(),
itemIds,
shouldHoldItems: item.holdItems,
}),
}));
});

if (item.linkedItems !== newLinkedItems) {
return {
linkedItems: newLinkedItems,
};
}

return {};
}, true);
},
[currentItemId, getItemList, setState]
);
Expand Down
19 changes: 13 additions & 6 deletions src/gameComponents/Image/Image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,24 @@ const Image = ({

const onPlaceItem = React.useCallback(
(itemIds) => {
setState((item) => ({
...item,
linkedItems: getHeldItems({
setState((item) => {
const newLinkedItems = getHeldItems({
element: wrapperRef.current,
currentItemId,
linkedItemIds: item.linkedItems,
currentLinkedItemIds: item.linkedItems,
itemList: getItemList(),
itemIds,
shouldHoldItems: item.holdItems,
}),
}));
});

if (item.linkedItems !== newLinkedItems) {
return {
linkedItems: newLinkedItems,
};
}

return {};
}, true);
},
[currentItemId, getItemList, setState]
);
Expand Down
19 changes: 13 additions & 6 deletions src/gameComponents/Zone/Zone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,24 @@ const Zone = ({

const onInsideItem = React.useCallback(
(itemIds) => {
setState((item) => ({
...item,
linkedItems: getHeldItems({
setState((item) => {
const newLinkedItems = getHeldItems({
element: zoneRef.current,
currentItemId,
linkedItemIds: item.linkedItems,
currentLinkedItemIds: item.linkedItems,
itemList: getItemList(),
itemIds,
shouldHoldItems: item.holdItems,
}),
}));
});

if (item.linkedItems !== newLinkedItems) {
return {
linkedItems: newLinkedItems,
};
}

return {};
}, true);

const addedItems = Object.entries(
areItemsInside(zoneRef.current, itemIds)
Expand Down
Loading

1 comment on commit 6e03f3f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.