1- import { Button } from '@invoke-ai/ui-library' ;
21import { logger } from 'app/logging/logger' ;
32import type { AppDispatch , RootState } from 'app/store/store' ;
4- import { useAppDispatch } from 'app/store/storeHooks' ;
53import type { SerializableObject } from 'common/types' ;
64import { deepClone } from 'common/util/deepClone' ;
75import { stagingAreaImageStaged } from 'features/controlLayers/store/canvasStagingAreaSlice' ;
8- import { $imageViewerState } from 'features/gallery/components/ImageViewer/useImageViewer' ;
96import { boardIdSelected , galleryViewChanged , imageSelected , offsetChanged } from 'features/gallery/store/gallerySlice' ;
107import { $nodeExecutionStates , upsertExecutionState } from 'features/nodes/hooks/useExecutionState' ;
118import { zNodeStatus } from 'features/nodes/types/invocation' ;
12- import { selectShowSendToToasts , showSendToToastsChanged } from 'features/system/store/systemSlice' ;
13- import { toast } from 'features/toast/toast' ;
14- import { selectActiveTab } from 'features/ui/store/uiSelectors' ;
15- import { useCallback } from 'react' ;
16- import { useTranslation } from 'react-i18next' ;
179import { boardsApi } from 'services/api/endpoints/boards' ;
1810import { getImageDTO , imagesApi } from 'services/api/endpoints/images' ;
1911import type { ImageDTO , S } from 'services/api/types' ;
@@ -25,55 +17,13 @@ const isCanvasOutputNode = (data: S['InvocationCompleteEvent']) => {
2517 return data . invocation_source_id . split ( ':' ) [ 0 ] === 'canvas_output' ;
2618} ;
2719
28- const SEND_TO_TOAST_ID = 'send-to-toast' ;
29-
30- const DontShowMeTheseToastDescription = ( ) => {
31- const { t } = useTranslation ( ) ;
32- const dispatch = useAppDispatch ( ) ;
33- const onClick = useCallback ( ( ) => {
34- dispatch ( showSendToToastsChanged ( false ) ) ;
35- } , [ dispatch ] ) ;
36-
37- return (
38- < Button onClick = { onClick } size = "sm" variant = "link" color = "base.50" >
39- { t ( 'common.dontShowMeThese' ) }
40- </ Button >
41- ) ;
42- } ;
43-
4420export const buildOnInvocationComplete = (
4521 getState : ( ) => RootState ,
4622 dispatch : AppDispatch ,
4723 nodeTypeDenylist : string [ ] ,
4824 setLastProgressEvent : ( event : S [ 'InvocationDenoiseProgressEvent' ] | null ) => void ,
4925 setLastCanvasProgressEvent : ( event : S [ 'InvocationDenoiseProgressEvent' ] | null ) => void
5026) => {
51- const toastIfUserIsLost = ( destination : string | null ) => {
52- const state = getState ( ) ;
53- const showToasts = selectShowSendToToasts ( state ) ;
54- if ( ! showToasts ) {
55- return ;
56- }
57- const tab = selectActiveTab ( state ) ;
58- if ( destination === 'canvas' && ( $imageViewerState . get ( ) || tab !== 'generation' ) ) {
59- toast ( {
60- id : SEND_TO_TOAST_ID ,
61- title : 'Image sent to Canvas' ,
62- updateDescription : true ,
63- withCount : false ,
64- description : < DontShowMeTheseToastDescription /> ,
65- } ) ;
66- } else if ( destination !== 'canvas' && ! $imageViewerState . get ( ) && tab === 'generation' ) {
67- toast ( {
68- id : SEND_TO_TOAST_ID ,
69- title : 'Image sent to Gallery' ,
70- updateDescription : true ,
71- withCount : false ,
72- description : < DontShowMeTheseToastDescription /> ,
73- } ) ;
74- }
75- } ;
76-
7727 const addImageToGallery = ( imageDTO : ImageDTO ) => {
7828 if ( imageDTO . is_intermediate ) {
7929 return ;
@@ -160,7 +110,6 @@ export const buildOnInvocationComplete = (
160110
161111 if ( imageDTO && ! imageDTO . is_intermediate ) {
162112 addImageToGallery ( imageDTO ) ;
163- toastIfUserIsLost ( data . destination ) ;
164113 }
165114 } ;
166115
@@ -180,13 +129,11 @@ export const buildOnInvocationComplete = (
180129 dispatch ( stagingAreaImageStaged ( { stagingAreaImage : { imageDTO, offsetX : 0 , offsetY : 0 } } ) ) ;
181130 }
182131 addImageToGallery ( imageDTO ) ;
183- toastIfUserIsLost ( data . destination ) ;
184132 }
185133 } else if ( ! imageDTO . is_intermediate ) {
186134 // session.mode === 'generate'
187135 setLastCanvasProgressEvent ( null ) ;
188136 addImageToGallery ( imageDTO ) ;
189- toastIfUserIsLost ( data . destination ) ;
190137 }
191138 } ;
192139
@@ -195,7 +142,6 @@ export const buildOnInvocationComplete = (
195142
196143 if ( imageDTO && ! imageDTO . is_intermediate ) {
197144 addImageToGallery ( imageDTO ) ;
198- toastIfUserIsLost ( data . destination ) ;
199145 }
200146 } ;
201147
0 commit comments