- {imageToDisplay ? (
+ {hasAnImageToDisplay ? (
<>
-
diff --git a/frontend/src/features/gallery/CurrentImagePreview.tsx b/frontend/src/features/gallery/CurrentImagePreview.tsx
index 0785878348..addbcc7cb7 100644
--- a/frontend/src/features/gallery/CurrentImagePreview.tsx
+++ b/frontend/src/features/gallery/CurrentImagePreview.tsx
@@ -3,7 +3,6 @@ import { useState } from 'react';
import { FaAngleLeft, FaAngleRight } from 'react-icons/fa';
import { RootState, useAppDispatch, useAppSelector } from '../../app/store';
import { GalleryState, selectNextImage, selectPrevImage } from './gallerySlice';
-import * as InvokeAI from '../../app/invokeai';
import { createSelector } from '@reduxjs/toolkit';
import _ from 'lodash';
import { OptionsState } from '../options/optionsSlice';
@@ -12,7 +11,7 @@ import ImageMetadataViewer from './ImageMetaDataViewer/ImageMetadataViewer';
export const imagesSelector = createSelector(
[(state: RootState) => state.gallery, (state: RootState) => state.options],
(gallery: GalleryState, options: OptionsState) => {
- const { currentCategory } = gallery;
+ const { currentCategory, currentImage, intermediateImage } = gallery;
const { shouldShowImageDetails } = options;
const tempImages = gallery.categories[currentCategory].images;
@@ -21,6 +20,7 @@ export const imagesSelector = createSelector(
);
const imagesLength = tempImages.length;
return {
+ imageToDisplay: intermediateImage ? intermediateImage : currentImage,
currentCategory,
isOnFirstImage: currentImageIndex === 0,
isOnLastImage:
@@ -38,16 +38,15 @@ export const imagesSelector = createSelector(
}
);
-interface CurrentImagePreviewProps {
- imageToDisplay: InvokeAI.Image;
-}
-
-export default function CurrentImagePreview(props: CurrentImagePreviewProps) {
- const { imageToDisplay } = props;
+export default function CurrentImagePreview() {
const dispatch = useAppDispatch();
- const { isOnFirstImage, isOnLastImage, shouldShowImageDetails } =
- useAppSelector(imagesSelector);
+ const {
+ isOnFirstImage,
+ isOnLastImage,
+ shouldShowImageDetails,
+ imageToDisplay,
+ } = useAppSelector(imagesSelector);
const [shouldShowNextPrevButtons, setShouldShowNextPrevButtons] =
useState
(false);
@@ -67,14 +66,17 @@ export default function CurrentImagePreview(props: CurrentImagePreviewProps) {
const handleClickNextButton = () => {
dispatch(selectNextImage());
};
+ console.log(imageToDisplay);
return (
-
+ {imageToDisplay && (
+
+ )}
{!shouldShowImageDetails && (
)}
- {shouldShowImageDetails && (
+ {shouldShowImageDetails && imageToDisplay && (
{
- if (isConnected && !isProcessing) {
+ if (isConnected && !isProcessing && image) {
dispatch(deleteImage(image));
}
onClose();
@@ -95,7 +95,7 @@ const DeleteImageModal = forwardRef(
<>
{cloneElement(children, {
// TODO: This feels wrong.
- onClick: handleClickDelete,
+ onClick: image ? handleClickDelete : undefined,
ref: ref,
})}