[bugfix/Refactor] Config Page: Device Tab. Fix render error when open config page before preparing backend.
And remove the code that is no longer in use.
This commit is contained in:
@@ -2,27 +2,15 @@ import styles from "./DropdownMenu.module.scss";
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import ArrowLeftSvg from "@images/arrow_left.svg?react";
|
import ArrowLeftSvg from "@images/arrow_left.svg?react";
|
||||||
import { useIsOpenedDropdownMenu } from "@store";
|
import { useIsOpenedDropdownMenu } from "@store";
|
||||||
import { useConfig } from "@logics/useConfig";
|
|
||||||
|
|
||||||
export const DropdownMenu = (props) => {
|
export const DropdownMenu = (props) => {
|
||||||
const { updateIsOpenedDropdownMenu, currentIsOpenedDropdownMenu } = useIsOpenedDropdownMenu();
|
const { updateIsOpenedDropdownMenu, currentIsOpenedDropdownMenu } = useIsOpenedDropdownMenu();
|
||||||
const { getMicHostList, getMicDeviceList } = useConfig();
|
|
||||||
|
|
||||||
const toggleDropdownMenu = () => {
|
const toggleDropdownMenu = () => {
|
||||||
if (currentIsOpenedDropdownMenu === props.dropdown_id) {
|
if (currentIsOpenedDropdownMenu === props.dropdown_id) {
|
||||||
updateIsOpenedDropdownMenu("");
|
updateIsOpenedDropdownMenu("");
|
||||||
} else {
|
} else {
|
||||||
switch (props.dropdown_id) {
|
if (props.openListFunction !== undefined) props.openListFunction();
|
||||||
case "mic_host":
|
|
||||||
getMicHostList();
|
|
||||||
break;
|
|
||||||
case "mic_device":
|
|
||||||
getMicDeviceList();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
updateIsOpenedDropdownMenu(props.dropdown_id);
|
updateIsOpenedDropdownMenu(props.dropdown_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -50,7 +38,6 @@ export const DropdownMenu = (props) => {
|
|||||||
const getSelectedText = () => {
|
const getSelectedText = () => {
|
||||||
if (props.state !== "hasData") return;
|
if (props.state !== "hasData") return;
|
||||||
return props.selected_id;
|
return props.selected_id;
|
||||||
// return (props.list[props.selected_id]) ? props.list[props.selected_id] : "Nothing selected";
|
|
||||||
};
|
};
|
||||||
const list = (props.list === undefined) ? {} : props.list;
|
const list = (props.list === undefined) ? {} : props.list;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import FolderOpenSvg from "@images/folder_open.svg?react";
|
|
||||||
|
|
||||||
import { useSettingBox } from "../components/useSettingBox";
|
import { useSettingBox } from "../components/useSettingBox";
|
||||||
import {
|
import {
|
||||||
useMicHostList,
|
useMicHostList,
|
||||||
@@ -28,6 +26,8 @@ export const Device = () => {
|
|||||||
const {
|
const {
|
||||||
setSelectedMicHost,
|
setSelectedMicHost,
|
||||||
setSelectedMicDevice,
|
setSelectedMicDevice,
|
||||||
|
getMicHostList,
|
||||||
|
getMicDeviceList,
|
||||||
} = useConfig();
|
} = useConfig();
|
||||||
|
|
||||||
const selectFunction = (selected_data) => {
|
const selectFunction = (selected_data) => {
|
||||||
@@ -54,6 +54,7 @@ export const Device = () => {
|
|||||||
selected_id={currentSelectedMicHost.data}
|
selected_id={currentSelectedMicHost.data}
|
||||||
list={currentMicHostList.data}
|
list={currentMicHostList.data}
|
||||||
selectFunction={selectFunction}
|
selectFunction={selectFunction}
|
||||||
|
openListFunction={getMicHostList}
|
||||||
state={currentSelectedMicHost.state}
|
state={currentSelectedMicHost.state}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ export const Device = () => {
|
|||||||
selected_id={currentSelectedMicDevice.data}
|
selected_id={currentSelectedMicDevice.data}
|
||||||
list={currentMicDeviceList.data}
|
list={currentMicDeviceList.data}
|
||||||
selectFunction={selectFunction}
|
selectFunction={selectFunction}
|
||||||
|
openListFunction={getMicDeviceList}
|
||||||
state={currentSelectedMicDevice.state}
|
state={currentSelectedMicDevice.state}
|
||||||
/>
|
/>
|
||||||
{/*
|
{/*
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
translator_list,
|
translator_list,
|
||||||
test_device_list,
|
|
||||||
generateTestData,
|
generateTestData,
|
||||||
word_filter_list,
|
word_filter_list,
|
||||||
} from "@data";
|
} from "@data";
|
||||||
|
|||||||
Reference in New Issue
Block a user