From 1e51c3992853ad4643d8eda2443a3bd0d65f5f90 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 2 Nov 2022 15:27:46 +1100 Subject: [PATCH] Fixes crash related to old value of progress_latents in state --- frontend/src/app/constants.ts | 13 +++++++++---- frontend/src/features/system/systemSlice.ts | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/constants.ts b/frontend/src/app/constants.ts index b46f7ec925..bd457dc7fb 100644 --- a/frontend/src/app/constants.ts +++ b/frontend/src/app/constants.ts @@ -1,5 +1,7 @@ // TODO: use Enums? +import { InProgressImageType } from '../features/system/systemSlice'; + // Valid samplers export const SAMPLERS: Array = [ 'ddim', @@ -38,8 +40,11 @@ export const NUMPY_RAND_MAX = 4294967295; export const FACETOOL_TYPES = ['gfpgan', 'codeformer'] as const; -export const IN_PROGRESS_IMAGE_TYPES: Array<{ key: string; value: string }> = [ - { key: "None", value: 'none'}, - { key: "Fast", value: 'latents' }, - { key: "Accurate", value: 'full-res' } +export const IN_PROGRESS_IMAGE_TYPES: Array<{ + key: string; + value: InProgressImageType; +}> = [ + { key: 'None', value: 'none' }, + { key: 'Fast', value: 'latents' }, + { key: 'Accurate', value: 'full-res' }, ]; diff --git a/frontend/src/features/system/systemSlice.ts b/frontend/src/features/system/systemSlice.ts index 19a95fd546..23f84f9916 100644 --- a/frontend/src/features/system/systemSlice.ts +++ b/frontend/src/features/system/systemSlice.ts @@ -20,10 +20,12 @@ export type ReadinessPayload = { reasonsWhyNotReady: string[]; }; +export type InProgressImageType = 'none' | 'full-res' | 'latents'; + export interface SystemState extends InvokeAI.SystemStatus, InvokeAI.SystemConfig { - shouldDisplayInProgressType: string; + shouldDisplayInProgressType: InProgressImageType; log: Array; shouldShowLogViewer: boolean; isGFPGANAvailable: boolean; @@ -43,12 +45,12 @@ export interface SystemState isCancelable: boolean; } -const initialSystemState = { +const initialSystemState: SystemState = { isConnected: false, isProcessing: false, log: [], shouldShowLogViewer: false, - shouldDisplayInProgressType: "none", + shouldDisplayInProgressType: 'none', shouldDisplayGuides: true, isGFPGANAvailable: true, isESRGANAvailable: true, @@ -70,17 +72,16 @@ const initialSystemState = { hasError: false, wasErrorSeen: true, isCancelable: true, - isReady: false, - reasonsWhyNotReady: [], }; -const initialState: SystemState = initialSystemState; - export const systemSlice = createSlice({ name: 'system', - initialState, + initialState: initialSystemState, reducers: { - setShouldDisplayInProgressType: (state, action: PayloadAction) => { + setShouldDisplayInProgressType: ( + state, + action: PayloadAction + ) => { state.shouldDisplayInProgressType = action.payload; }, setIsProcessing: (state, action: PayloadAction) => {