@@ -6,8 +6,6 @@ import { $bulkDownloadId } from 'app/store/nanostores/bulkDownloadId';
6
6
import { $queueId } from 'app/store/nanostores/queueId' ;
7
7
import type { AppStore } from 'app/store/store' ;
8
8
import { deepClone } from 'common/util/deepClone' ;
9
- import { $isHFForbiddenToastOpen } from 'features/modelManagerV2/hooks/useHFForbiddenToast' ;
10
- import { $isHFLoginToastOpen } from 'features/modelManagerV2/hooks/useHFLoginToast' ;
11
9
import { $nodeExecutionStates , upsertExecutionState } from 'features/nodes/hooks/useExecutionState' ;
12
10
import { zNodeStatus } from 'features/nodes/types/invocation' ;
13
11
import ErrorToastDescription , { getTitleFromErrorType } from 'features/toast/ErrorToastDescription' ;
@@ -19,6 +17,7 @@ import { api, LIST_TAG } from 'services/api';
19
17
import { modelsApi } from 'services/api/endpoints/models' ;
20
18
import { queueApi , queueItemsAdapter } from 'services/api/endpoints/queue' ;
21
19
import { buildOnInvocationComplete } from 'services/events/onInvocationComplete' ;
20
+ import { buildOnModelInstallError } from 'services/events/onModelInstallError' ;
22
21
import type { ClientToServerEvents , ServerToClientEvents } from 'services/events/types' ;
23
22
import type { Socket } from 'socket.io-client' ;
24
23
import type { JsonObject } from 'type-fest' ;
@@ -291,36 +290,8 @@ export const setEventListeners = ({ socket, store, setIsConnected }: SetEventLis
291
290
dispatch ( api . util . invalidateTags ( [ { type : 'ModelScanFolderResults' , id : LIST_TAG } ] ) ) ;
292
291
} ) ;
293
292
294
- socket . on ( 'model_install_error' , ( data ) => {
295
- log . error ( { data } , 'Model install error' ) ;
296
-
297
- const { id, error, error_type } = data ;
298
- const installs = selectModelInstalls ( getState ( ) ) . data ;
299
-
300
- if ( error === 'Unauthorized' ) {
301
- $isHFLoginToastOpen . set ( true ) ;
302
- }
303
-
304
- if ( error === 'Forbidden' ) {
305
- $isHFForbiddenToastOpen . set ( { isEnabled : true , source : data . source } ) ;
306
- }
307
-
308
- if ( ! installs ?. find ( ( install ) => install . id === id ) ) {
309
- dispatch ( api . util . invalidateTags ( [ { type : 'ModelInstalls' } ] ) ) ;
310
- } else {
311
- dispatch (
312
- modelsApi . util . updateQueryData ( 'listModelInstalls' , undefined , ( draft ) => {
313
- const modelImport = draft . find ( ( m ) => m . id === id ) ;
314
- if ( modelImport ) {
315
- modelImport . status = 'error' ;
316
- modelImport . error_reason = error_type ;
317
- modelImport . error = error ;
318
- }
319
- return draft ;
320
- } )
321
- ) ;
322
- }
323
- } ) ;
293
+ const onModelInstallError = buildOnModelInstallError ( getState , dispatch ) ;
294
+ socket . on ( 'model_install_error' , onModelInstallError ) ;
324
295
325
296
socket . on ( 'model_install_cancelled' , ( data ) => {
326
297
log . warn ( { data } , 'Model install cancelled' ) ;
0 commit comments