mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): no duplicate network requests on app startup
This commit is contained in:
parent
eb2fcbe28a
commit
8954953eca
@ -4,6 +4,7 @@ import { api } from 'services/api';
|
||||
import { receivedOpenAPISchema } from 'services/api/thunks/schema';
|
||||
import { appSocketConnected, socketConnected } from 'services/events/actions';
|
||||
import { startAppListening } from '../..';
|
||||
import { isInitializedChanged } from 'features/system/store/systemSlice';
|
||||
|
||||
export const addSocketConnectedEventListener = () => {
|
||||
startAppListening({
|
||||
@ -13,7 +14,7 @@ export const addSocketConnectedEventListener = () => {
|
||||
|
||||
log.debug('Connected');
|
||||
|
||||
const { nodes, config } = getState();
|
||||
const { nodes, config, system } = getState();
|
||||
|
||||
const { disabledTabs } = config;
|
||||
|
||||
@ -21,7 +22,12 @@ export const addSocketConnectedEventListener = () => {
|
||||
dispatch(receivedOpenAPISchema());
|
||||
}
|
||||
|
||||
dispatch(api.util.resetApiState());
|
||||
if (system.isInitialized) {
|
||||
// only reset the query caches if this connect event is a *reconnect* event
|
||||
dispatch(api.util.resetApiState());
|
||||
} else {
|
||||
dispatch(isInitializedChanged(true));
|
||||
}
|
||||
|
||||
// pass along the socket event as an application action
|
||||
dispatch(appSocketConnected(action.payload));
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { logger } from 'app/logging/logger';
|
||||
import { api } from 'services/api';
|
||||
import {
|
||||
appSocketDisconnected,
|
||||
socketDisconnected,
|
||||
@ -13,8 +12,6 @@ export const addSocketDisconnectedEventListener = () => {
|
||||
const log = logger('socketio');
|
||||
log.debug('Disconnected');
|
||||
|
||||
dispatch(api.util.resetApiState());
|
||||
|
||||
// pass along the socket event as an application action
|
||||
dispatch(appSocketDisconnected(action.payload));
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { SystemState } from './types';
|
||||
|
||||
export const systemPersistDenylist: (keyof SystemState)[] = [
|
||||
'isInitialized',
|
||||
'isConnected',
|
||||
'denoiseProgress',
|
||||
'status',
|
||||
|
@ -24,6 +24,7 @@ import { SystemState, LANGUAGES } from './types';
|
||||
import { zPydanticValidationError } from './zodSchemas';
|
||||
|
||||
export const initialSystemState: SystemState = {
|
||||
isInitialized: false,
|
||||
isConnected: false,
|
||||
shouldConfirmOnDelete: true,
|
||||
enableImageDebugging: false,
|
||||
@ -82,6 +83,9 @@ export const systemSlice = createSlice({
|
||||
) {
|
||||
state.shouldEnableInformationalPopovers = action.payload;
|
||||
},
|
||||
isInitializedChanged(state, action: PayloadAction<boolean>) {
|
||||
state.isInitialized = action.payload;
|
||||
},
|
||||
},
|
||||
extraReducers(builder) {
|
||||
/**
|
||||
@ -242,6 +246,7 @@ export const {
|
||||
shouldUseNSFWCheckerChanged,
|
||||
shouldUseWatermarkerChanged,
|
||||
setShouldEnableInformationalPopovers,
|
||||
isInitializedChanged,
|
||||
} = systemSlice.actions;
|
||||
|
||||
export default systemSlice.reducer;
|
||||
|
@ -21,6 +21,7 @@ export type DenoiseProgress = {
|
||||
};
|
||||
|
||||
export interface SystemState {
|
||||
isInitialized: boolean;
|
||||
isConnected: boolean;
|
||||
shouldConfirmOnDelete: boolean;
|
||||
enableImageDebugging: boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user