From a00347379bd103da0c45645047743ea905a7407f Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Tue, 15 Oct 2024 10:10:40 -0400 Subject: [PATCH] feat(ui): move layers/gallery tab state into redux so it persists across sessions/refreshes, make gallery the default --- .../web/src/app/hooks/useStudioInitAction.ts | 3 +- .../CanvasAlerts/CanvasAlertsSendingTo.tsx | 13 ++--- .../components/CanvasRightPanel.tsx | 51 +++++++++++++------ .../NewSessionConfirmationAlertDialog.tsx | 9 ++-- .../hooks/useCanvasDeleteLayerHotkey.ts | 6 +-- .../features/controlLayers/store/ephemeral.ts | 15 +----- .../gallery/hooks/useGalleryHotkeys.ts | 6 +-- .../queue/components/SendToToggle.tsx | 5 +- .../web/src/features/ui/store/uiSelectors.ts | 1 + .../web/src/features/ui/store/uiSlice.ts | 7 ++- .../web/src/features/ui/store/uiTypes.ts | 5 ++ 11 files changed, 64 insertions(+), 57 deletions(-) diff --git a/invokeai/frontend/web/src/app/hooks/useStudioInitAction.ts b/invokeai/frontend/web/src/app/hooks/useStudioInitAction.ts index 1f8f7ddac6..a48311e5f2 100644 --- a/invokeai/frontend/web/src/app/hooks/useStudioInitAction.ts +++ b/invokeai/frontend/web/src/app/hooks/useStudioInitAction.ts @@ -12,7 +12,7 @@ import { parseAndRecallAllMetadata } from 'features/metadata/util/handlers'; import { $isWorkflowListMenuIsOpen } from 'features/nodes/store/workflowListMenu'; import { $isStylePresetsMenuOpen, activeStylePresetIdChanged } from 'features/stylePresets/store/stylePresetSlice'; import { toast } from 'features/toast/toast'; -import { setActiveTab } from 'features/ui/store/uiSlice'; +import { activeTabCanvasRightPanelChanged, setActiveTab } from 'features/ui/store/uiSlice'; import { useGetAndLoadLibraryWorkflow } from 'features/workflowLibrary/hooks/useGetAndLoadLibraryWorkflow'; import { useCallback, useEffect, useRef } from 'react'; import { useTranslation } from 'react-i18next'; @@ -140,6 +140,7 @@ export const useStudioInitAction = (action?: StudioInitAction) => { case 'generation': // Go to the canvas tab, open the image viewer, and enable send-to-gallery mode store.dispatch(setActiveTab('canvas')); + store.dispatch(activeTabCanvasRightPanelChanged('gallery')); store.dispatch(settingsSendToCanvasChanged(false)); $imageViewer.set(true); break; diff --git a/invokeai/frontend/web/src/features/controlLayers/components/CanvasAlerts/CanvasAlertsSendingTo.tsx b/invokeai/frontend/web/src/features/controlLayers/components/CanvasAlerts/CanvasAlertsSendingTo.tsx index 67df7ee3a1..16791ee7e6 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/CanvasAlerts/CanvasAlertsSendingTo.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/CanvasAlerts/CanvasAlertsSendingTo.tsx @@ -2,14 +2,10 @@ import { Alert, AlertDescription, AlertIcon, AlertTitle, Button, Flex } from '@i import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useBoolean } from 'common/hooks/useBoolean'; import { selectIsStaging } from 'features/controlLayers/store/canvasStagingAreaSlice'; -import { - selectCanvasRightPanelGalleryTab, - selectCanvasRightPanelLayersTab, -} from 'features/controlLayers/store/ephemeral'; import { useImageViewer } from 'features/gallery/components/ImageViewer/useImageViewer'; import { useCurrentDestination } from 'features/queue/hooks/useCurrentDestination'; import { selectActiveTab } from 'features/ui/store/uiSelectors'; -import { setActiveTab } from 'features/ui/store/uiSlice'; +import { activeTabCanvasRightPanelChanged, setActiveTab } from 'features/ui/store/uiSlice'; import { AnimatePresence, motion } from 'framer-motion'; import type { PropsWithChildren, ReactNode } from 'react'; import { useCallback, useMemo } from 'react'; @@ -17,10 +13,11 @@ import { Trans, useTranslation } from 'react-i18next'; const ActivateImageViewerButton = (props: PropsWithChildren) => { const imageViewer = useImageViewer(); + const dispatch = useAppDispatch(); const onClick = useCallback(() => { imageViewer.open(); - selectCanvasRightPanelGalleryTab(); - }, [imageViewer]); + dispatch(activeTabCanvasRightPanelChanged('gallery')); + }, [imageViewer, dispatch]); return (