fix(ui): model install progress sets total bytes correctly

This commit is contained in:
psychedelicious 2024-02-27 15:52:06 +11:00
parent 80065858ed
commit b218282149

View File

@ -12,13 +12,14 @@ export const addModelInstallEventListener = () => {
startAppListening({ startAppListening({
actionCreator: socketModelInstallDownloading, actionCreator: socketModelInstallDownloading,
effect: async (action, { dispatch }) => { effect: async (action, { dispatch }) => {
const { bytes, id } = action.payload.data; const { bytes, total_bytes, id } = action.payload.data;
dispatch( dispatch(
modelsApi.util.updateQueryData('getModelImports', undefined, (draft) => { modelsApi.util.updateQueryData('getModelImports', undefined, (draft) => {
const modelImport = draft.find((m) => m.id === id); const modelImport = draft.find((m) => m.id === id);
if (modelImport) { if (modelImport) {
modelImport.bytes = bytes; modelImport.bytes = bytes;
modelImport.total_bytes = total_bytes;
modelImport.status = 'downloading'; modelImport.status = 'downloading';
} }
return draft; return draft;
@ -48,7 +49,7 @@ export const addModelInstallEventListener = () => {
startAppListening({ startAppListening({
actionCreator: socketModelInstallError, actionCreator: socketModelInstallError,
effect: (action, { dispatch }) => { effect: (action, { dispatch }) => {
const { id, error_type } = action.payload.data; const { id, error, error_type } = action.payload.data;
dispatch( dispatch(
modelsApi.util.updateQueryData('getModelImports', undefined, (draft) => { modelsApi.util.updateQueryData('getModelImports', undefined, (draft) => {
@ -56,6 +57,7 @@ export const addModelInstallEventListener = () => {
if (modelImport) { if (modelImport) {
modelImport.status = 'error'; modelImport.status = 'error';
modelImport.error_reason = error_type; modelImport.error_reason = error_type;
modelImport.error = error;
} }
return draft; return draft;
}) })