Lf94/pause improvements (#3032)
* Add stream idle mode as a setting (default is off) * Add pause icon
This commit is contained in:
@ -1,11 +1,16 @@
|
||||
import { createContext, useContext } from 'react'
|
||||
import {
|
||||
ConnectingTypeGroup,
|
||||
EngineConnectionStateType,
|
||||
EngineConnectionState,
|
||||
initialConnectingTypeGroupState,
|
||||
} from '../lang/std/engineConnection'
|
||||
import { NetworkStatus, NetworkHealthState } from './useNetworkStatus'
|
||||
|
||||
export const NetworkContext = createContext<NetworkStatus>({
|
||||
immediateState: {
|
||||
type: EngineConnectionStateType.Disconnected,
|
||||
} as EngineConnectionState,
|
||||
hasIssues: undefined,
|
||||
overallState: NetworkHealthState.Disconnected,
|
||||
internetConnected: true,
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
EngineCommandManagerEvents,
|
||||
EngineConnectionEvents,
|
||||
EngineConnectionStateType,
|
||||
EngineConnectionState,
|
||||
ErrorType,
|
||||
initialConnectingTypeGroupState,
|
||||
} from '../lang/std/engineConnection'
|
||||
@ -19,6 +20,7 @@ export enum NetworkHealthState {
|
||||
}
|
||||
|
||||
export interface NetworkStatus {
|
||||
immediateState: EngineConnectionState
|
||||
hasIssues: boolean | undefined
|
||||
overallState: NetworkHealthState
|
||||
internetConnected: boolean
|
||||
@ -33,6 +35,9 @@ export interface NetworkStatus {
|
||||
// Must be called from one place in the application.
|
||||
// We've chosen the <Router /> component for this.
|
||||
export function useNetworkStatus() {
|
||||
const [immediateState, setImmediateState] = useState<EngineConnectionState>({
|
||||
type: EngineConnectionStateType.Disconnected,
|
||||
})
|
||||
const [steps, setSteps] = useState(
|
||||
structuredClone(initialConnectingTypeGroupState)
|
||||
)
|
||||
@ -126,6 +131,7 @@ export function useNetworkStatus() {
|
||||
const onConnectionStateChange = ({
|
||||
detail: engineConnectionState,
|
||||
}: CustomEvent) => {
|
||||
setImmediateState(engineConnectionState)
|
||||
setSteps((steps) => {
|
||||
let nextSteps = structuredClone(steps)
|
||||
|
||||
@ -215,6 +221,7 @@ export function useNetworkStatus() {
|
||||
}, [])
|
||||
|
||||
return {
|
||||
immediateState,
|
||||
hasIssues,
|
||||
overallState,
|
||||
internetConnected,
|
||||
|
Reference in New Issue
Block a user