It just works

This commit is contained in:
2023-01-12 19:00:53 +01:00
parent 733e2ab006
commit d93fc37943
5 changed files with 28 additions and 7 deletions

View File

@@ -163,7 +163,7 @@ function AppContent() {
<Toolbar />
<Routes>
<Route path="/" element={<Home socket={socket} />} />
<Route path="/settings" element={<Settings />} />
<Route path="/settings" element={<Settings socket={socket} />} />
</Routes>
</Box>
</Box>

View File

@@ -22,6 +22,7 @@ import { useDispatch, useSelector } from "react-redux";
import { debounceTime, distinctUntilChanged, map, of, takeWhile } from "rxjs";
import { CliArguments } from "./features/core/argsParser";
import I18nBuilder from "./features/core/intl";
import { RPCClient } from "./features/core/rpcClient";
import {
LanguageUnion,
setCliArgs,
@@ -38,7 +39,7 @@ import { updated } from "./features/status/statusSlice";
import { RootState } from "./stores/store";
import { validateDomain, validateIP } from "./utils";
export default function Settings() {
export default function Settings({ socket }: { socket: WebSocket }) {
const settings = useSelector((state: RootState) => state.settings)
const status = useSelector((state: RootState) => state.status)
const dispatch = useDispatch()
@@ -46,6 +47,7 @@ export default function Settings() {
const [invalidIP, setInvalidIP] = useState(false);
const i18n = useMemo(() => new I18nBuilder(settings.language), [settings.language])
const client = useMemo(() => new RPCClient(socket), [settings.serverAddr, settings.serverPort])
const cliArgs = useMemo(() => new CliArguments().fromString(settings.cliArgs), [settings.cliArgs])
/**
* Update the server ip address state and localstorage whenever the input value changes.
@@ -107,7 +109,7 @@ export default function Settings() {
* Send via WebSocket a message in order to update the yt-dlp binary from server
*/
const updateBinary = () => {
client.updateExecutable().then(() => dispatch(updated()))
}
return (

View File

@@ -92,6 +92,13 @@ export class RPCClient {
})
}
public updateExecutable() {
return this.sendHTTP({
method: 'Service.UpdateExecutable',
params: []
})
}
public decode(data: any): RPCResponse<any> {
return JSON.parse(data)
}