feat: reconnecting status
This commit is contained in:
@@ -3,7 +3,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|||||||
import { UploadFileData } from "@/hooks/useUploadFile";
|
import { UploadFileData } from "@/hooks/useUploadFile";
|
||||||
|
|
||||||
export type ListView = "item" | "grid";
|
export type ListView = "item" | "grid";
|
||||||
export type SSEStatus = "connecting" | "connected" | "disconnected";
|
export type SSEStatus = "connecting" | "connected" | "disconnected" | "reconnecting";
|
||||||
export interface UIState {
|
export interface UIState {
|
||||||
SSEStatus: SSEStatus;
|
SSEStatus: SSEStatus;
|
||||||
online: boolean;
|
online: boolean;
|
||||||
@@ -46,8 +46,9 @@ const uiSlice = createSlice({
|
|||||||
name: "ui",
|
name: "ui",
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
fillUI(state, action) {
|
fillUI(state, action: PayloadAction<Partial<UIState>>) {
|
||||||
return { ...initialState, ...action.payload };
|
const { SSEStatus, ready, online, ...rest } = action.payload;
|
||||||
|
return { ...state, ...rest };
|
||||||
},
|
},
|
||||||
setReady(state) {
|
setReady(state) {
|
||||||
state.ready = true;
|
state.ready = true;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { useAppSelector } from "@/app/store";
|
import { useAppSelector } from "@/app/store";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
// import { useEffect } from "react";
|
||||||
|
// import { toast } from "react-hot-toast";
|
||||||
import { shallowEqual } from "react-redux";
|
import { shallowEqual } from "react-redux";
|
||||||
// import React from "react";
|
|
||||||
|
|
||||||
type Props = {};
|
// type Props = {};
|
||||||
|
const StreamStatus = () => {
|
||||||
const StreamStatus = (props: Props) => {
|
|
||||||
const status = useAppSelector((store) => store.ui.SSEStatus, shallowEqual);
|
const status = useAppSelector((store) => store.ui.SSEStatus, shallowEqual);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className="fixed right-2 bottom-2">
|
<aside className="fixed right-2 bottom-2">
|
||||||
<div
|
<div
|
||||||
@@ -14,6 +15,7 @@ const StreamStatus = (props: Props) => {
|
|||||||
"w-1 h-1 rounded-full",
|
"w-1 h-1 rounded-full",
|
||||||
status === "connected" && "bg-green-500",
|
status === "connected" && "bg-green-500",
|
||||||
status === "disconnected" && "bg-red-500",
|
status === "disconnected" && "bg-red-500",
|
||||||
|
status === "reconnecting" && "bg-blue-500",
|
||||||
status === "connecting" && "bg-yellow-500"
|
status === "connecting" && "bg-yellow-500"
|
||||||
)}
|
)}
|
||||||
></div>
|
></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user