Skip to content

Commit

Permalink
Merge pull request #10898 from DestinyItemManager/double-click
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis authored Jan 19, 2025
2 parents b4e2eb3 + 8fbc682 commit bdccb49
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/app/search/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { t } from 'app/i18next-t';
import ConnectedInventoryItem from 'app/inventory/ConnectedInventoryItem';
import DraggableInventoryItem from 'app/inventory/DraggableInventoryItem';
import ItemPopupTrigger from 'app/inventory/ItemPopupTrigger';
import { moveItemToCurrentStore } from 'app/inventory/move-item';
import { useThunkDispatch } from 'app/store/thunk-dispatch';
import clsx from 'clsx';
import { memo } from 'react';
import { memo, useCallback } from 'react';
import { useSelector } from 'react-redux';
import Sheet from '../dim-ui/Sheet';
import '../inventory-page/StoreBucket.scss';
Expand Down Expand Up @@ -43,16 +45,33 @@ export default memo(function SearchResults({
<ClickOutsideRoot>
<div className={clsx('sub-bucket', styles.contents)}>
{sortItems(items).map((item) => (
<DraggableInventoryItem key={item.index} item={item}>
<ItemPopupTrigger item={item} key={item.index}>
{(ref, onClick) => (
<ConnectedInventoryItem item={item} ref={ref} onClick={onClick} />
)}
</ItemPopupTrigger>
</DraggableInventoryItem>
<SearchResultItem key={item.index} item={item} />
))}
</div>
</ClickOutsideRoot>
</Sheet>
);
});

function SearchResultItem({ item }: { item: DimItem }) {
const dispatch = useThunkDispatch();
const doubleClicked = useCallback(
(e: React.MouseEvent) => dispatch(moveItemToCurrentStore(item, e)),
[dispatch, item],
);

return (
<DraggableInventoryItem item={item}>
<ItemPopupTrigger item={item} key={item.index}>
{(ref, onClick) => (
<ConnectedInventoryItem
item={item}
ref={ref}
onClick={onClick}
onDoubleClick={doubleClicked}
/>
)}
</ItemPopupTrigger>
</DraggableInventoryItem>
);
}

0 comments on commit bdccb49

Please sign in to comment.