fix(ui): reduce reconnect requests

- Add checks to the "recovery" logic for socket connect events to reduce the number of network requests.
- Remove the `isInitialized` state from `systemSlice` and make it a nanostore local to the socketConnected listener. It didn't need to be global state. It's also now more clearly named `isFirstConnection`.
- Export the queue status selector (minor improvement, memoizes it correctly).
This commit is contained in:
psychedelicious
2024-01-09 11:26:34 +11:00
parent 7fc08962fb
commit 7dea079220
5 changed files with 87 additions and 19 deletions

View File

@ -26,7 +26,6 @@ import type { Language, SystemState } from './types';
export const initialSystemState: SystemState = {
_version: 1,
isInitialized: false,
isConnected: false,
shouldConfirmOnDelete: true,
enableImageDebugging: false,
@ -85,9 +84,6 @@ export const systemSlice = createSlice({
) {
state.shouldEnableInformationalPopovers = action.payload;
},
isInitializedChanged(state, action: PayloadAction<boolean>) {
state.isInitialized = action.payload;
},
},
extraReducers(builder) {
/**
@ -206,7 +202,6 @@ export const {
shouldUseNSFWCheckerChanged,
shouldUseWatermarkerChanged,
setShouldEnableInformationalPopovers,
isInitializedChanged,
} = systemSlice.actions;
export default systemSlice.reducer;

View File

@ -44,7 +44,6 @@ export const isLanguage = (v: unknown): v is Language =>
export interface SystemState {
_version: 1;
isInitialized: boolean;
isConnected: boolean;
shouldConfirmOnDelete: boolean;
enableImageDebugging: boolean;