mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): block gallery navigation when staging images on canvas
This commit is contained in:
parent
287d3c2b04
commit
c4291f2136
@ -1,11 +1,22 @@
|
||||
import { useAppSelector } from 'app/store/storeHooks';
|
||||
import { isStagingSelector } from 'features/canvas/store/canvasSelectors';
|
||||
import { useGalleryImages } from 'features/gallery/hooks/useGalleryImages';
|
||||
import { useGalleryNavigation } from 'features/gallery/hooks/useGalleryNavigation';
|
||||
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
||||
import { useMemo } from 'react';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
/**
|
||||
* Registers gallery hotkeys. This hook is a singleton.
|
||||
*/
|
||||
export const useGalleryHotkeys = () => {
|
||||
const activeTabName = useAppSelector(activeTabNameSelector);
|
||||
const isStaging = useAppSelector(isStagingSelector);
|
||||
// block navigation on Unified Canvas tab when staging new images
|
||||
const canNavigateGallery = useMemo(() => {
|
||||
return activeTabName !== 'unifiedCanvas' || !isStaging;
|
||||
}, [activeTabName, isStaging]);
|
||||
|
||||
const {
|
||||
areMoreImagesAvailable,
|
||||
handleLoadMoreImages,
|
||||
@ -18,14 +29,17 @@ export const useGalleryHotkeys = () => {
|
||||
useHotkeys(
|
||||
'left',
|
||||
() => {
|
||||
handleLeftImage();
|
||||
canNavigateGallery && handleLeftImage();
|
||||
},
|
||||
[handleLeftImage]
|
||||
[handleLeftImage, canNavigateGallery]
|
||||
);
|
||||
|
||||
useHotkeys(
|
||||
'right',
|
||||
() => {
|
||||
if (!canNavigateGallery) {
|
||||
return;
|
||||
}
|
||||
if (isOnLastImage && areMoreImagesAvailable && !isFetching) {
|
||||
handleLoadMoreImages();
|
||||
return;
|
||||
@ -34,7 +48,7 @@ export const useGalleryHotkeys = () => {
|
||||
handleRightImage();
|
||||
}
|
||||
},
|
||||
[isOnLastImage, areMoreImagesAvailable, handleLoadMoreImages, isFetching, handleRightImage]
|
||||
[isOnLastImage, areMoreImagesAvailable, handleLoadMoreImages, isFetching, handleRightImage, canNavigateGallery]
|
||||
);
|
||||
|
||||
useHotkeys(
|
||||
|
Loading…
Reference in New Issue
Block a user