mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
fix(ui): simplify model install event listeners
This commit is contained in:
@@ -15,13 +15,12 @@ export const addModelInstallEventListener = () => {
|
||||
|
||||
dispatch(
|
||||
modelsApi.util.updateQueryData('getModelImports', undefined, (draft) => {
|
||||
const models = JSON.parse(JSON.stringify(draft))
|
||||
|
||||
const modelIndex = models.findIndex((m) => m.id === id);
|
||||
|
||||
models[modelIndex].bytes = bytes;
|
||||
models[modelIndex].status = 'downloading';
|
||||
return models;
|
||||
const modelImport = draft.find((m) => m.id === id);
|
||||
if (modelImport) {
|
||||
modelImport.bytes = bytes;
|
||||
modelImport.status = 'downloading';
|
||||
}
|
||||
return draft;
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -34,12 +33,11 @@ export const addModelInstallEventListener = () => {
|
||||
|
||||
dispatch(
|
||||
modelsApi.util.updateQueryData('getModelImports', undefined, (draft) => {
|
||||
const models = JSON.parse(JSON.stringify(draft))
|
||||
|
||||
const modelIndex = models.findIndex((m) => m.id === id);
|
||||
|
||||
models[modelIndex].status = 'completed';
|
||||
return models;
|
||||
const modelImport = draft.find((m) => m.id === id);
|
||||
if (modelImport) {
|
||||
modelImport.status = 'completed';
|
||||
}
|
||||
return draft;
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -52,12 +50,11 @@ export const addModelInstallEventListener = () => {
|
||||
|
||||
dispatch(
|
||||
modelsApi.util.updateQueryData('getModelImports', undefined, (draft) => {
|
||||
const models = JSON.parse(JSON.stringify(draft))
|
||||
|
||||
const modelIndex = models.findIndex((m) => m.id === id);
|
||||
|
||||
models[modelIndex].status = 'error';
|
||||
return models;
|
||||
const modelImport = draft.find((m) => m.id === id);
|
||||
if (modelImport) {
|
||||
modelImport.status = 'error';
|
||||
}
|
||||
return draft;
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user