feat(ui): update useGlobalModifiers to store each key independently

This reduces rerenders when the user presses a modifier key.
This commit is contained in:
psychedelicious
2024-01-01 15:55:11 +11:00
committed by Kent Keirsey
parent 7e2eeec1f3
commit 5c3dd62ae0
5 changed files with 30 additions and 39 deletions

View File

@ -6,7 +6,7 @@ import { useAppDispatch } from 'app/store/storeHooks';
import IAIDndImage from 'common/components/IAIDndImage';
import IAIDndImageIcon from 'common/components/IAIDndImageIcon';
import IAIFillSkeleton from 'common/components/IAIFillSkeleton';
import { $modifiers } from 'common/hooks/useGlobalModifiers';
import { $shift } from 'common/hooks/useGlobalModifiers';
import { imagesToDeleteSelected } from 'features/deleteImageModal/store/slice';
import type {
ImageDraggableData,
@ -42,7 +42,7 @@ const GalleryImage = (props: HoverableImageProps) => {
const dispatch = useAppDispatch();
const { imageName, virtuosoContext } = props;
const { currentData: imageDTO } = useGetImageDTOQuery(imageName);
const { shift } = useStore($modifiers);
const shift = useStore($shift);
const { t } = useTranslation();
const { handleClick, isSelected, selection, selectionCount } =