refactor: prefetch basic data and window visibility change event in streaming

This commit is contained in:
Tristan Yang
2023-08-23 23:06:12 +08:00
parent 1ae9b0e55f
commit 488b9b301c
12 changed files with 452 additions and 285 deletions
+9 -2
View File
@@ -3,7 +3,9 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { UploadFileData } from "@/hooks/useUploadFile";
export type ListView = "item" | "grid";
export interface State {
export type SSEStatus = "connecting" | "connected" | "disconnected";
export interface UIState {
SSEStatus: SSEStatus;
online: boolean;
ready: boolean;
inputMode: "text";
@@ -22,7 +24,8 @@ export interface State {
};
}
const initialState: State = {
const initialState: UIState = {
SSEStatus: "disconnected",
online: true,
ready: false,
inputMode: "text",
@@ -49,6 +52,9 @@ const uiSlice = createSlice({
setReady(state) {
state.ready = true;
},
updateSSEStatus(state, action: PayloadAction<SSEStatus>) {
state.SSEStatus = action.payload;
},
updateOnline(state, action: PayloadAction<boolean>) {
state.online = action.payload;
},
@@ -171,6 +177,7 @@ const uiSlice = createSlice({
});
export const {
updateSSEStatus,
fillUI,
setReady,
updateOnline,