[Update/bugfix] UI: Add disable/enable UI function when osc query is disabled.
Fix the error that the mic mute sync couldn't enable/disable.
This commit is contained in:
@@ -11,5 +11,6 @@ export { useMessage } from "./useMessage";
|
||||
export { useUpdateSoftware } from "./useUpdateSoftware";
|
||||
export { useVolume } from "./useVolume";
|
||||
export { useHandleNetworkConnection } from "./useHandleNetworkConnection";
|
||||
export { useHandleOscQuery } from "./useHandleOscQuery";
|
||||
export { useIsVrctAvailable } from "./useIsVrctAvailable";
|
||||
export { useFetch } from "./useFetch";
|
||||
44
src-ui/logics/common/useHandleOscQuery.js
Normal file
44
src-ui/logics/common/useHandleOscQuery.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNotificationStatus } from "@logics_common";
|
||||
import {
|
||||
useEnableVrcMicMuteSync,
|
||||
} from "@logics_configs";
|
||||
|
||||
export const useHandleOscQuery = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { showNotification_Warning } = useNotificationStatus();
|
||||
const { updateEnableVrcMicMuteSync } = useEnableVrcMicMuteSync();
|
||||
|
||||
const handleOscQuery = ({is_osc_query_enabled, disabled_functions}) => {
|
||||
if (!is_osc_query_enabled && disabled_functions.length > 0) {
|
||||
const BASE_LABEL = t("common_warning.unable_to_use_osc_query");
|
||||
let items_label = "";
|
||||
|
||||
for (const disabled_function of disabled_functions) {
|
||||
if (disabled_function === "vrc_mic_mute_sync") {
|
||||
updateEnableVrcMicMuteSync({
|
||||
is_enabled: !is_osc_query_enabled,
|
||||
is_available: false,
|
||||
});
|
||||
const item = `- ${t("config_page.others.vrc_mic_mute_sync.label")}`;
|
||||
items_label = `${items_label}\n${item}`;
|
||||
}
|
||||
}
|
||||
const label = `${BASE_LABEL}${items_label}`;
|
||||
showNotification_Warning(
|
||||
label,
|
||||
{ hide_duration: 10000, }
|
||||
);
|
||||
} else if (is_osc_query_enabled) {
|
||||
updateEnableVrcMicMuteSync((old_value) => ({
|
||||
...old_value.data,
|
||||
is_available: true,
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
handleOscQuery,
|
||||
};
|
||||
};
|
||||
@@ -5,6 +5,16 @@ export const useNotificationStatus = () => {
|
||||
|
||||
const generateRandomKey = () => Math.random();
|
||||
|
||||
const showNotification_Warning = (message, options = {}) => {
|
||||
updateNotificationStatus({
|
||||
status: "warning",
|
||||
is_open: true,
|
||||
key: generateRandomKey(),
|
||||
message: message,
|
||||
options: options,
|
||||
});
|
||||
};
|
||||
|
||||
const showNotification_Error = (message, options = {}) => {
|
||||
updateNotificationStatus({
|
||||
status: "error",
|
||||
@@ -37,6 +47,7 @@ export const useNotificationStatus = () => {
|
||||
currentNotificationStatus,
|
||||
updateNotificationStatus,
|
||||
|
||||
showNotification_Warning,
|
||||
showNotification_Error,
|
||||
showNotification_Success,
|
||||
closeNotification,
|
||||
|
||||
Reference in New Issue
Block a user