From b8b20595583c549fbb77ea1f5b5e3658ff51ce95 Mon Sep 17 00:00:00 2001 From: Jixun Wu Date: Fri, 16 Jun 2023 02:03:23 +0100 Subject: [PATCH] fix: performance issue when there's over 100s ekeys --- .../settings/panels/PanelQMCv2Key.tsx | 58 +++--------------- .../settings/panels/QMCv2/KeyInput.tsx | 59 +++++++++++++++++++ 2 files changed, 66 insertions(+), 51 deletions(-) create mode 100644 src/features/settings/panels/QMCv2/KeyInput.tsx diff --git a/src/features/settings/panels/PanelQMCv2Key.tsx b/src/features/settings/panels/PanelQMCv2Key.tsx index e485d4b..8b7e7e7 100644 --- a/src/features/settings/panels/PanelQMCv2Key.tsx +++ b/src/features/settings/panels/PanelQMCv2Key.tsx @@ -7,26 +7,21 @@ import { Heading, Icon, IconButton, - Input, - InputGroup, - InputLeftElement, - InputRightElement, List, - ListItem, Menu, MenuButton, MenuDivider, MenuItem, MenuList, Text, - VStack, } from '@chakra-ui/react'; import { useDispatch, useSelector } from 'react-redux'; -import { qmc2AddKey, qmc2ClearKeys, qmc2DeleteKey, qmc2UpdateKey } from '../settingsSlice'; +import { qmc2AddKey, qmc2ClearKeys } from '../settingsSlice'; import { selectStagingQMCv2Settings } from '../settingsSelector'; -import React, { useState } from 'react'; -import { MdAdd, MdDelete, MdDeleteForever, MdExpandMore, MdFileUpload, MdVpnKey } from 'react-icons/md'; +import { useState } from 'react'; +import { MdAdd, MdDeleteForever, MdExpandMore, MdFileUpload } from 'react-icons/md'; import { ImportFileModal } from './QMCv2/ImportFileModal'; +import { KeyInput } from './QMCv2/KeyInput'; export function PanelQMCv2Key() { const dispatch = useDispatch(); @@ -34,9 +29,6 @@ export function PanelQMCv2Key() { const [showImportModal, setShowImportModal] = useState(false); const addKey = () => dispatch(qmc2AddKey()); - const updateKey = (prop: 'name' | 'key', id: string, e: React.ChangeEvent) => - dispatch(qmc2UpdateKey({ id, field: prop, value: e.target.value })); - const deleteKey = (id: string) => dispatch(qmc2DeleteKey({ id })); const clearAll = () => dispatch(qmc2ClearKeys()); return ( @@ -50,7 +42,7 @@ export function PanelQMCv2Key() { 客户端的情况下,其「离线加密文件」对应的「密钥」储存在独立的数据库文件内。 - +