-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): update studio destination options and get them all working w…
…ith new tab and store values
- Loading branch information
Showing
3 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
invokeai/frontend/web/src/app/hooks/useHandleStudioDestination.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useAppDispatch } from 'app/store/storeHooks'; | ||
import { settingsSendToCanvasChanged } from 'features/controlLayers/store/canvasSettingsSlice'; | ||
import { useImageViewer } from 'features/gallery/components/ImageViewer/useImageViewer'; | ||
import { $isMenuOpen } from 'features/stylePresets/store/isMenuOpen'; | ||
import { setActiveTab } from 'features/ui/store/uiSlice'; | ||
import { $isWorkflowLibraryModalOpen } from 'features/workflowLibrary/store/isWorkflowLibraryModalOpen'; | ||
import { useCallback } from 'react'; | ||
|
||
export type StudioDestination = | ||
| 'generation' | ||
| 'canvas' | ||
| 'workflows' | ||
| 'upscaling' | ||
| 'viewAllWorkflows' | ||
| 'viewAllStylePresets'; | ||
|
||
export const useHandleStudioDestination = () => { | ||
const dispatch = useAppDispatch(); | ||
const imageViewer = useImageViewer(); | ||
|
||
const handleStudioDestination = useCallback( | ||
(destination: StudioDestination) => { | ||
switch (destination) { | ||
case 'generation': | ||
dispatch(setActiveTab('canvas')); | ||
dispatch(settingsSendToCanvasChanged(false)); | ||
imageViewer.open(); | ||
break; | ||
case 'canvas': | ||
dispatch(setActiveTab('canvas')); | ||
dispatch(settingsSendToCanvasChanged(true)); | ||
imageViewer.close(); | ||
break; | ||
case 'workflows': | ||
dispatch(setActiveTab('workflows')); | ||
break; | ||
case 'upscaling': | ||
dispatch(setActiveTab('upscaling')); | ||
break; | ||
case 'viewAllWorkflows': | ||
dispatch(setActiveTab('workflows')); | ||
$isWorkflowLibraryModalOpen.set(true); | ||
break; | ||
case 'viewAllStylePresets': | ||
dispatch(setActiveTab('canvas')); | ||
$isMenuOpen.set(true); | ||
break; | ||
default: | ||
dispatch(setActiveTab('canvas')); | ||
break; | ||
} | ||
}, | ||
[dispatch, imageViewer] | ||
); | ||
|
||
return handleStudioDestination; | ||
}; |