From 04baafcc469d55fceed0a440c93b62455193d635 Mon Sep 17 00:00:00 2001 From: Pylogmon Date: Sun, 23 Jun 2024 21:59:41 +0800 Subject: [PATCH] revert: available check --- .../Config/pages/Service/Collection/index.jsx | 67 +++++++--------- .../Config/pages/Service/Recognize/index.jsx | 67 +++++++--------- .../Config/pages/Service/Translate/index.jsx | 68 +++++++---------- src/window/Config/pages/Service/Tts/index.jsx | 67 +++++++--------- src/window/Recognize/ControlArea/index.jsx | 65 +++++++--------- src/window/Translate/index.jsx | 76 ++++++++----------- 6 files changed, 176 insertions(+), 234 deletions(-) diff --git a/src/window/Config/pages/Service/Collection/index.jsx b/src/window/Config/pages/Service/Collection/index.jsx index 0eb36afa85..89eb473603 100644 --- a/src/window/Config/pages/Service/Collection/index.jsx +++ b/src/window/Config/pages/Service/Collection/index.jsx @@ -9,8 +9,6 @@ import { useConfig, deleteKey } from '../../../../../hooks'; import ServiceItem from './ServiceItem'; import SelectModal from './SelectModal'; import ConfigModal from './ConfigModal'; -import * as builtinCollectionServices from '../../../../../services/collection'; -import { ServiceSourceType, whetherAvailableService } from '../../../../../utils/service_instance'; export default function Collection(props) { const { pluginList } = props; @@ -71,42 +69,35 @@ export default function Collection(props) { {...provided.droppableProps} > {collectionServiceInstanceList !== null && - collectionServiceInstanceList - .filter((instanceKey) => { - return whetherAvailableService(instanceKey, { - [ServiceSourceType.BUILDIN]: builtinCollectionServices, - [ServiceSourceType.PLUGIN]: pluginList, - }); - }) - .map((x, i) => { - return ( - - {(provided) => { - return ( -
- - -
- ); - }} -
- ); - })} + collectionServiceInstanceList.map((x, i) => { + return ( + + {(provided) => { + return ( +
+ + +
+ ); + }} +
+ ); + })} )} diff --git a/src/window/Config/pages/Service/Recognize/index.jsx b/src/window/Config/pages/Service/Recognize/index.jsx index 68b7e2f0d7..719d191c63 100644 --- a/src/window/Config/pages/Service/Recognize/index.jsx +++ b/src/window/Config/pages/Service/Recognize/index.jsx @@ -11,8 +11,6 @@ import { useConfig, deleteKey } from '../../../../../hooks'; import ServiceItem from './ServiceItem'; import SelectModal from './SelectModal'; import ConfigModal from './ConfigModal'; -import * as builtinRecognizeServices from '../../../../../services/recognize'; -import { ServiceSourceType, whetherAvailableService } from '../../../../../utils/service_instance'; export default function Recognize(props) { const { pluginList } = props; @@ -83,42 +81,35 @@ export default function Recognize(props) { {...provided.droppableProps} > {recognizeServiceInstanceList !== null && - recognizeServiceInstanceList - .filter((instanceKey) => { - return whetherAvailableService(instanceKey, { - [ServiceSourceType.BUILDIN]: builtinRecognizeServices, - [ServiceSourceType.PLUGIN]: pluginList, - }); - }) - .map((x, i) => { - return ( - - {(provided) => { - return ( -
- - -
- ); - }} -
- ); - })} + recognizeServiceInstanceList.map((x, i) => { + return ( + + {(provided) => { + return ( +
+ + +
+ ); + }} +
+ ); + })} )} diff --git a/src/window/Config/pages/Service/Translate/index.jsx b/src/window/Config/pages/Service/Translate/index.jsx index ec585f4dcf..859b4c6835 100644 --- a/src/window/Config/pages/Service/Translate/index.jsx +++ b/src/window/Config/pages/Service/Translate/index.jsx @@ -12,9 +12,6 @@ import ServiceItem from './ServiceItem'; import SelectModal from './SelectModal'; import ConfigModal from './ConfigModal'; -import * as builtinTranslateServices from '../../../../../services/translate'; -import { ServiceSourceType, whetherAvailableService } from '../../../../../utils/service_instance'; - export default function Translate(props) { const { pluginList } = props; const { @@ -86,42 +83,35 @@ export default function Translate(props) { {...provided.droppableProps} > {translateServiceInstanceList !== null && - translateServiceInstanceList - .filter((instanceKey) => { - return whetherAvailableService(instanceKey, { - [ServiceSourceType.BUILDIN]: builtinTranslateServices, - [ServiceSourceType.PLUGIN]: pluginList, - }); - }) - .map((x, i) => { - return ( - - {(provided) => { - return ( -
- - -
- ); - }} -
- ); - })} + translateServiceInstanceList.map((x, i) => { + return ( + + {(provided) => { + return ( +
+ + +
+ ); + }} +
+ ); + })} )} diff --git a/src/window/Config/pages/Service/Tts/index.jsx b/src/window/Config/pages/Service/Tts/index.jsx index 72042943fc..67e8a7e2d3 100644 --- a/src/window/Config/pages/Service/Tts/index.jsx +++ b/src/window/Config/pages/Service/Tts/index.jsx @@ -11,8 +11,6 @@ import { useConfig, deleteKey } from '../../../../../hooks'; import ServiceItem from './ServiceItem'; import SelectModal from './SelectModal'; import ConfigModal from './ConfigModal'; -import * as builtinTtsServices from '../../../../../services/tts'; -import { ServiceSourceType, whetherAvailableService } from '../../../../../utils/service_instance'; export default function Tts(props) { const { pluginList } = props; @@ -80,42 +78,35 @@ export default function Tts(props) { {...provided.droppableProps} > {ttsServiceInstanceList !== null && - ttsServiceInstanceList - .filter((instanceKey) => { - return whetherAvailableService(instanceKey, { - [ServiceSourceType.BUILDIN]: builtinTtsServices, - [ServiceSourceType.PLUGIN]: pluginList, - }); - }) - .map((x, i) => { - return ( - - {(provided) => { - return ( -
- - -
- ); - }} -
- ); - })} + ttsServiceInstanceList.map((x, i) => { + return ( + + {(provided) => { + return ( +
+ + +
+ ); + }} +
+ ); + })} )} diff --git a/src/window/Recognize/ControlArea/index.jsx b/src/window/Recognize/ControlArea/index.jsx index ba285b1898..75acb183e4 100644 --- a/src/window/Recognize/ControlArea/index.jsx +++ b/src/window/Recognize/ControlArea/index.jsx @@ -13,7 +13,6 @@ import { textAtom } from '../TextArea'; import { pluginListAtom } from '..'; import { osType } from '../../../utils/env'; import { - whetherAvailableService, ServiceSourceType, getServiceSouceType, getServiceName, @@ -89,42 +88,34 @@ export default function ControlArea(props) { setCurrentServiceInstanceKey(key); }} > - {serviceInstanceList - .filter((instanceKey) => { - return whetherAvailableService(instanceKey, { - [ServiceSourceType.BUILDIN]: builtinService, - [ServiceSourceType.PLUGIN]: pluginList, - }); - }) - .map((instanceKey) => { - return ( - - } - > - {getServiceSouceType(instanceKey) === ServiceSourceType.PLUGIN - ? getInstanceName( - instanceKey, - () => pluginList[getServiceName(instanceKey)].display - ) - : getInstanceName(instanceKey, () => - t(`services.recognize.${instanceKey}.title`) - )} - - ); - })} + {serviceInstanceList.map((instanceKey) => { + return ( + + } + > + {getServiceSouceType(instanceKey) === ServiceSourceType.PLUGIN + ? getInstanceName( + instanceKey, + () => pluginList[getServiceName(instanceKey)].display + ) + : getInstanceName(instanceKey, () => + t(`services.recognize.${instanceKey}.title`) + )} + + ); + })} )} diff --git a/src/window/Translate/index.jsx b/src/window/Translate/index.jsx index 7f01783473..0378144680 100644 --- a/src/window/Translate/index.jsx +++ b/src/window/Translate/index.jsx @@ -17,9 +17,6 @@ import { useConfig } from '../../hooks'; import { store } from '../../utils/store'; import { info } from 'tauri-plugin-log-api'; -import * as builtinTranslateServices from '../../services/translate'; -import { ServiceSourceType, ServiceType, whetherAvailableService } from '../../utils/service_instance'; - let blurTimeout = null; let resizeTimeout = null; let moveTimeout = null; @@ -299,48 +296,39 @@ export default function Translate() { > {translateServiceInstanceList !== null && serviceInstanceConfigMap !== null && - translateServiceInstanceList - .filter((serviceInstanceKey) => { - return whetherAvailableService(serviceInstanceKey, { - [ServiceSourceType.PLUGIN]: pluginList[ServiceType.TRANSLATE], - [ServiceSourceType.BUILDIN]: builtinTranslateServices, - }); - }) - .map((serviceInstanceKey, index) => { - const config = serviceInstanceConfigMap[serviceInstanceKey] ?? {}; - const enable = config['enable'] ?? true; + translateServiceInstanceList.map((serviceInstanceKey, index) => { + const config = serviceInstanceConfigMap[serviceInstanceKey] ?? {}; + const enable = config['enable'] ?? true; - return enable ? ( - - {(provided) => ( -
- - -
- )} -
- ) : ( - <> - ); - })} + return enable ? ( + + {(provided) => ( +
+ + +
+ )} +
+ ) : ( + <> + ); + })} )}