mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): disable gallery hotkeys while staging
This commit is contained in:
parent
02c4b28de5
commit
954cb129a4
@ -9,7 +9,7 @@ import { useListImagesQuery } from 'services/api/endpoints/images';
|
|||||||
* Registers gallery hotkeys. This hook is a singleton.
|
* Registers gallery hotkeys. This hook is a singleton.
|
||||||
*/
|
*/
|
||||||
export const useGalleryHotkeys = () => {
|
export const useGalleryHotkeys = () => {
|
||||||
// TODO(psyche): Hotkeys when staging - cannot navigate gallery with arrow keys when staging!
|
const isStaging = useAppSelector((s) => s.canvasV2.stagingArea.isStaging);
|
||||||
|
|
||||||
const { goNext, goPrev, isNextEnabled, isPrevEnabled } = useGalleryPagination();
|
const { goNext, goPrev, isNextEnabled, isPrevEnabled } = useGalleryPagination();
|
||||||
const queryArgs = useAppSelector(selectListImagesQueryArgs);
|
const queryArgs = useAppSelector(selectListImagesQueryArgs);
|
||||||
@ -41,6 +41,9 @@ export const useGalleryHotkeys = () => {
|
|||||||
useHotkeys(
|
useHotkeys(
|
||||||
['right', 'alt+right'],
|
['right', 'alt+right'],
|
||||||
(e) => {
|
(e) => {
|
||||||
|
if (isStaging) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isOnLastImageOfView && isNextEnabled && !queryResult.isFetching) {
|
if (isOnLastImageOfView && isNextEnabled && !queryResult.isFetching) {
|
||||||
goNext(e.altKey ? 'alt+arrow' : 'arrow');
|
goNext(e.altKey ? 'alt+arrow' : 'arrow');
|
||||||
return;
|
return;
|
||||||
@ -49,12 +52,15 @@ export const useGalleryHotkeys = () => {
|
|||||||
handleRightImage(e.altKey);
|
handleRightImage(e.altKey);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[isOnLastImageOfView, goNext, isNextEnabled, queryResult.isFetching, handleRightImage]
|
[isStaging, isOnLastImageOfView, goNext, isNextEnabled, queryResult.isFetching, handleRightImage]
|
||||||
);
|
);
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
['up', 'alt+up'],
|
['up', 'alt+up'],
|
||||||
(e) => {
|
(e) => {
|
||||||
|
if (isStaging) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isOnFirstRow && isPrevEnabled && !queryResult.isFetching) {
|
if (isOnFirstRow && isPrevEnabled && !queryResult.isFetching) {
|
||||||
goPrev(e.altKey ? 'alt+arrow' : 'arrow');
|
goPrev(e.altKey ? 'alt+arrow' : 'arrow');
|
||||||
return;
|
return;
|
||||||
@ -62,12 +68,15 @@ export const useGalleryHotkeys = () => {
|
|||||||
handleUpImage(e.altKey);
|
handleUpImage(e.altKey);
|
||||||
},
|
},
|
||||||
{ preventDefault: true },
|
{ preventDefault: true },
|
||||||
[handleUpImage, canNavigateGallery, isOnFirstRow, goPrev, isPrevEnabled, queryResult.isFetching]
|
[isStaging, handleUpImage, isOnFirstRow, goPrev, isPrevEnabled, queryResult.isFetching]
|
||||||
);
|
);
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
['down', 'alt+down'],
|
['down', 'alt+down'],
|
||||||
(e) => {
|
(e) => {
|
||||||
|
if (isStaging) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isOnLastRow && isNextEnabled && !queryResult.isFetching) {
|
if (isOnLastRow && isNextEnabled && !queryResult.isFetching) {
|
||||||
goNext(e.altKey ? 'alt+arrow' : 'arrow');
|
goNext(e.altKey ? 'alt+arrow' : 'arrow');
|
||||||
return;
|
return;
|
||||||
@ -75,6 +84,6 @@ export const useGalleryHotkeys = () => {
|
|||||||
handleDownImage(e.altKey);
|
handleDownImage(e.altKey);
|
||||||
},
|
},
|
||||||
{ preventDefault: true },
|
{ preventDefault: true },
|
||||||
[isOnLastRow, goNext, isNextEnabled, queryResult.isFetching, handleDownImage]
|
[isStaging, isOnLastRow, goNext, isNextEnabled, queryResult.isFetching, handleDownImage]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user