Files
VRCT/src-ui/logics/configs/advanced_settings/useOscIpAddress.js
2025-03-21 17:38:15 +09:00

33 lines
1.0 KiB
JavaScript

import { useStore_OscIpAddress } from "@store";
import { useStdoutToPython } from "@logics/useStdoutToPython";
import { useNotificationStatus } from "@logics_common";
export const useOscIpAddress = () => {
const { showNotification_Error } = useNotificationStatus();
const { asyncStdoutToPython } = useStdoutToPython();
const { currentOscIpAddress, updateOscIpAddress, pendingOscIpAddress } = useStore_OscIpAddress();
const getOscIpAddress = () => {
pendingOscIpAddress();
asyncStdoutToPython("/get/data/osc_ip_address");
};
const setOscIpAddress = (osc_ip_address) => {
pendingOscIpAddress();
asyncStdoutToPython("/set/data/osc_ip_address", osc_ip_address);
};
const saveErrorOscIpAddress = ({data, message, _result}) => {
updateOscIpAddress(d => d.data);
showNotification_Error(_result);
};
return {
currentOscIpAddress,
getOscIpAddress,
updateOscIpAddress,
setOscIpAddress,
saveErrorOscIpAddress,
};
};