[Update] AdvancedSettings: OSC IP Address: Add error notifications.

Add 500 status error message.
This commit is contained in:
Sakamoto Shiina
2025-03-22 17:28:31 +09:00
parent df344baa06
commit a5e59af885
3 changed files with 20 additions and 22 deletions

View File

@@ -15,9 +15,7 @@ import {
useDeepLAuthKey,
useOscIpAddress,
useOscPort,
} from "@logics_configs";
import { ui_configs } from "../ui_configs";
@@ -35,9 +33,7 @@ export const _useBackendErrorHandling = () => {
const { updateDeepLAuthKey, saveErrorDeepLAuthKey } = useDeepLAuthKey();
const { saveErrorOscIpAddress } = useOscIpAddress();
const { saveErrorOscPort } = useOscPort();
const { updateOscIpAddress } = useOscIpAddress();
const errorHandling_Backend = ({message, data, endpoint, _result}) => {
switch (message) {
@@ -118,12 +114,21 @@ export const _useBackendErrorHandling = () => {
showNotification_Error(t("common_error.invalid_value_speaker_max_phrase"));
break;
// Advanced Settings, error messages are set by Backend (EN only)
case "Invalid IP address":
updateOscIpAddress(data);
showNotification_Error(message);
break;
case "Cannot set IP address":
updateOscIpAddress(data);
showNotification_Error(message);
break;
default:
// determine by endpoint, not message.
if (endpoint === "/set/data/deepl_auth_key") saveErrorDeepLAuthKey({message, data, endpoint, _result});
if (endpoint === "/set/data/osc_ip_address") saveErrorOscIpAddress({message, data, endpoint, _result});
if (endpoint === "/set/data/osc_port") saveErrorOscPort({message, data, endpoint, _result});
break;
}

View File

@@ -1,9 +1,7 @@
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();
@@ -17,17 +15,10 @@ export const useOscIpAddress = () => {
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,
};
};

View File

@@ -525,7 +525,6 @@ export const useReceiveRoutes = () => {
"/set/data/speaker_max_phrases": errorHandling_Backend,
"/set/data/osc_ip_address": errorHandling_Backend,
"/set/data/osc_port": errorHandling_Backend,
};
@@ -558,7 +557,6 @@ export const useReceiveRoutes = () => {
break;
case 400:
case 500:
const error_route = error_status_routes[parsed_data.endpoint];
if (error_route) {
error_route({
@@ -571,6 +569,10 @@ export const useReceiveRoutes = () => {
handleInvalidEndpoint(parsed_data);
}
break;
case 500:
showNotification_Error(
`An error occurred. Please restart VRCT or contact the developers. ${JSON.stringify(parsed_data.result)}`, { hide_duration: null });
break;
case 348:
// console.log(`from backend: %c ${JSON.stringify(parsed_data)}`, style_348);