[Fix/Update] FIx OSC availability handling and integrate into UI components.

This commit is contained in:
Sakamoto Shiina
2025-11-18 07:22:20 +09:00
parent d22c6c8f0c
commit fbbc1a8d45
8 changed files with 71 additions and 42 deletions

View File

@@ -12,5 +12,6 @@ export { useUpdateSoftware } from "./useUpdateSoftware";
export { useVolume } from "./useVolume";
export { useHandleNetworkConnection } from "./useHandleNetworkConnection";
export { useHandleOscQuery } from "./useHandleOscQuery";
export { useIsOscAvailable } from "./useIsOscAvailable";
export { useIsVrctAvailable } from "./useIsVrctAvailable";
export { useFetch } from "./useFetch";

View File

@@ -1,45 +1,36 @@
import { useI18n } from "@useI18n";
import { useNotificationStatus } from "@logics_common";
import { useOthers } from "@logics_configs";
import {
useNotificationStatus,
useIsOscAvailable,
} from "@logics_common";
export const useHandleOscQuery = () => {
const { t } = useI18n();
const { showNotification_Warning } = useNotificationStatus();
const { updateEnableVrcMicMuteSync } = useOthers();
const { updateIsOscAvailable } = useIsOscAvailable();
const handleOscQuery = (payload) => {
const is_osc_query_enabled = payload.data;
const disabled_functions = payload.disabled_functions;
// OSC無効になるのは、OSC IP Addressが127.0.0.1、localhost以外の場合で発生。
if (is_osc_query_enabled) {
updateEnableVrcMicMuteSync(prev => ({
...prev.data,
is_available: true,
}));
return;
}
updateIsOscAvailable(true);
if (!disabled_functions.length) {
updateEnableVrcMicMuteSync(prev => ({
...prev.data,
is_available: false,
}));
return;
}
} else { // OSC自体は無効だが、無効になった機能がない場合。
updateIsOscAvailable(false);
const items_label = disabled_functions
.filter(fn => fn === "vrc_mic_mute_sync")
.map(() => `- ${t("config_page.others.vrc_mic_mute_sync.label")}`)
.join("\n");
if (disabled_functions.length > 0) { // 無効になった機能がある場合は通知。
const items_label = disabled_functions
.filter(fn => fn === "vrc_mic_mute_sync")
.map(() => `- ${t("config_page.others.vrc_mic_mute_sync.label")}`)
.join("\n");
updateEnableVrcMicMuteSync({
is_enabled: false,
is_available: false,
});
if (items_label) {
const message = `${t("common_warning.unable_to_use_osc_query")}\n${items_label}`;
showNotification_Warning(message, { hide_duration: 10000 });
if (items_label) {
const message = `${t("common_warning.unable_to_use_osc_query")}\n${items_label}`;
showNotification_Warning(message, { hide_duration: 10000 });
}
}
}
};

View File

@@ -0,0 +1,10 @@
import { useStore_IsOscAvailable } from "@store";
export const useIsOscAvailable = () => {
const { currentIsOscAvailable, updateIsOscAvailable } = useStore_IsOscAvailable();
return {
currentIsOscAvailable,
updateIsOscAvailable,
};
};

View File

@@ -146,6 +146,7 @@ export const registerMany = (settingsArray = []) => {
// Common
export const { atomInstance: Atom_IsBackendReady, useHook: useStore_IsBackendReady } = createAtomWithHook(false, "IsBackendReady");
export const { atomInstance: Atom_IsVrctAvailable, useHook: useStore_IsVrctAvailable } = createAtomWithHook(true, "IsVrctAvailable");
export const { atomInstance: Atom_IsOscAvailable, useHook: useStore_IsOscAvailable } = createAtomWithHook(true, "IsOscAvailable");
export const { atomInstance: Atom_ComputeMode, useHook: useStore_ComputeMode } = createAtomWithHook("", "ComputeMode");
export const { atomInstance: Atom_IsOpenedConfigPage, useHook: useStore_IsOpenedConfigPage } = createAtomWithHook(false, "IsOpenedConfigPage");
export const { atomInstance: Atom_MainFunctionsStateMemory, useHook: useStore_MainFunctionsStateMemory } = createAtomWithHook({