[Refactor] (Huge Refactoring 2)
Consolidated all logic into category-specific files. Renamed useTranslation from react-i18next to useI18n to avoid a name conflict with our own function.
This commit is contained in:
@@ -1,16 +1,54 @@
|
||||
import {
|
||||
useStore_OscIpAddress,
|
||||
useStore_OscPort,
|
||||
useStore_EnableWebsocket,
|
||||
useStore_WebsocketHost,
|
||||
useStore_WebsocketPort,
|
||||
} from "@store";
|
||||
import { useStdoutToPython } from "@useStdoutToPython";
|
||||
import { useNotificationStatus } from "@logics_common";
|
||||
|
||||
export const useWebsocket = () => {
|
||||
export const useAdvancedSettings = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { showNotification_Error } = useNotificationStatus();
|
||||
|
||||
// OSC IP Address
|
||||
const { currentOscIpAddress, updateOscIpAddress, pendingOscIpAddress } = useStore_OscIpAddress();
|
||||
// OSC Port
|
||||
const { currentOscPort, updateOscPort, pendingOscPort } = useStore_OscPort();
|
||||
// WebSocket
|
||||
const { currentEnableWebsocket, updateEnableWebsocket, pendingEnableWebsocket } = useStore_EnableWebsocket();
|
||||
const { currentWebsocketHost, updateWebsocketHost, pendingWebsocketHost } = useStore_WebsocketHost();
|
||||
const { currentWebsocketPort, updateWebsocketPort, pendingWebsocketPort } = useStore_WebsocketPort();
|
||||
|
||||
// OSC IP Address
|
||||
const getOscIpAddress = () => {
|
||||
pendingOscIpAddress();
|
||||
asyncStdoutToPython("/get/data/osc_ip_address");
|
||||
};
|
||||
|
||||
const setOscIpAddress = (osc_ip_address) => {
|
||||
pendingOscIpAddress();
|
||||
asyncStdoutToPython("/set/data/osc_ip_address", osc_ip_address);
|
||||
};
|
||||
|
||||
// OSC Port
|
||||
const getOscPort = () => {
|
||||
pendingOscPort();
|
||||
asyncStdoutToPython("/get/data/osc_port");
|
||||
};
|
||||
|
||||
const setOscPort = (osc_port) => {
|
||||
pendingOscPort();
|
||||
asyncStdoutToPython("/set/data/osc_port", osc_port);
|
||||
};
|
||||
|
||||
const saveErrorOscPort = ({data, message, _result}) => {
|
||||
updateOscPort(d => d.data);
|
||||
showNotification_Error(_result);
|
||||
};
|
||||
|
||||
// WebSocket
|
||||
const getEnableWebsocket = () => {
|
||||
pendingEnableWebsocket();
|
||||
asyncStdoutToPython("/get/data/websocket_server");
|
||||
@@ -47,7 +85,22 @@ export const useWebsocket = () => {
|
||||
asyncStdoutToPython("/set/data/websocket_port", websocket_port);
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
// OSC IP Address
|
||||
currentOscIpAddress,
|
||||
getOscIpAddress,
|
||||
updateOscIpAddress,
|
||||
setOscIpAddress,
|
||||
|
||||
// OSC Port
|
||||
currentOscPort,
|
||||
getOscPort,
|
||||
updateOscPort,
|
||||
setOscPort,
|
||||
saveErrorOscPort,
|
||||
|
||||
// WebSocket
|
||||
currentEnableWebsocket,
|
||||
updateEnableWebsocket,
|
||||
getEnableWebsocket,
|
||||
@@ -62,6 +115,5 @@ export const useWebsocket = () => {
|
||||
updateWebsocketPort,
|
||||
getWebsocketPort,
|
||||
setWebsocketPort,
|
||||
|
||||
};
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { useStore_OscIpAddress } from "@store";
|
||||
import { useStdoutToPython } from "@useStdoutToPython";
|
||||
|
||||
export const useOscIpAddress = () => {
|
||||
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);
|
||||
};
|
||||
|
||||
return {
|
||||
currentOscIpAddress,
|
||||
getOscIpAddress,
|
||||
updateOscIpAddress,
|
||||
setOscIpAddress,
|
||||
};
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
import { useStore_OscPort } from "@store";
|
||||
import { useStdoutToPython } from "@useStdoutToPython";
|
||||
import { useNotificationStatus } from "@logics_common";
|
||||
|
||||
export const useOscPort = () => {
|
||||
const { showNotification_Error } = useNotificationStatus();
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentOscPort, updateOscPort, pendingOscPort } = useStore_OscPort();
|
||||
|
||||
const getOscPort = () => {
|
||||
pendingOscPort();
|
||||
asyncStdoutToPython("/get/data/osc_port");
|
||||
};
|
||||
|
||||
const setOscPort = (osc_port) => {
|
||||
pendingOscPort();
|
||||
asyncStdoutToPython("/set/data/osc_port", osc_port);
|
||||
};
|
||||
|
||||
const saveErrorOscPort = ({data, message, _result}) => {
|
||||
updateOscPort(d => d.data);
|
||||
showNotification_Error(_result);
|
||||
};
|
||||
|
||||
return {
|
||||
currentOscPort,
|
||||
getOscPort,
|
||||
updateOscPort,
|
||||
setOscPort,
|
||||
|
||||
saveErrorOscPort,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user