import React, { useContext, useState, useEffect } from 'react'; import { Typography, Slider } from 'antd'; import { ServerStatusContext } from '../../utils/server-status-context'; const { Title } = Typography; const SLIDER_MARKS = { 1: 'lowest', 2: '', 3: '', 4: '', 5: 'highest', }; const TOOLTIPS = { 1: 'lowest', 2: 'low', 3: 'medium', 4: 'high', 5: 'highest', }; interface Props { defaultValue: number; onChange: (arg: number) => void; } export default function CPUUsageSelector({ defaultValue, onChange }: Props) { const [selectedOption, setSelectedOption] = useState(null); const serverStatusData = useContext(ServerStatusContext); const { serverConfig } = serverStatusData || {}; const { videoSettings } = serverConfig || {}; if (!videoSettings) { return null; } useEffect(() => { setSelectedOption(defaultValue); }, [videoSettings]); const handleChange = value => { setSelectedOption(value); onChange(value); }; return (
Reduce the to improve server performance, or increase it to improve video quality.
Selected: {TOOLTIPS[selectedOption]}