2025-06-17 18:31:30 +02:00
|
|
|
import { createSlice, type PayloadAction } from "@reduxjs/toolkit"
|
2025-06-27 16:29:31 +02:00
|
|
|
import { reloadServerInfos } from "@/app/server/thunks"
|
|
|
|
|
import type { ServerInfo } from "@/app/types"
|
2024-06-13 21:54:14 +02:00
|
|
|
|
|
|
|
|
interface ServerState {
|
|
|
|
|
serverInfos?: ServerInfo
|
|
|
|
|
webSocketConnected: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const initialState: ServerState = {
|
|
|
|
|
webSocketConnected: false,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const serverSlice = createSlice({
|
|
|
|
|
name: "server",
|
|
|
|
|
initialState,
|
|
|
|
|
reducers: {
|
|
|
|
|
setWebSocketConnected: (state, action: PayloadAction<boolean>) => {
|
|
|
|
|
state.webSocketConnected = action.payload
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
extraReducers: builder => {
|
|
|
|
|
builder.addCase(reloadServerInfos.fulfilled, (state, action) => {
|
|
|
|
|
state.serverInfos = action.payload
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export const { setWebSocketConnected } = serverSlice.actions
|