From 7dc25bfa9553283b60c23f62715abbce68076956 Mon Sep 17 00:00:00 2001 From: QiShaoXuan <474021214@qq.com> Date: Mon, 1 Aug 2022 17:37:18 +0800 Subject: [PATCH] fixed: when remove all tag, editor will throw error in tag history popover, fixed #20 --- .../PendantHistoryPanel.tsx | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx b/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx index ce47f80e27..5fdd24788c 100644 --- a/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx +++ b/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx @@ -26,7 +26,6 @@ export const PendantHistoryPanel = ({ const { getProperties } = useRecastBlockMeta(); const { getProperty } = useRecastBlockMeta(); - const { getAllValue } = getRecastItemValue(block); const recastBlock = useRecastBlock(); const [history, setHistory] = useState([]); @@ -34,7 +33,7 @@ export const PendantHistoryPanel = ({ useEffect(() => { const init = async () => { - const currentBlockValues = getAllValue(); + const currentBlockValues = getRecastItemValue(block).getAllValue(); const allProperties = getProperties(); const missProperties = allProperties.filter( property => !currentBlockValues.find(v => v.id === property.id) @@ -52,24 +51,26 @@ export const PendantHistoryPanel = ({ return history; }, {}); - const blockHistory = await Promise.all( - Object.entries(historyMap).map( - async ([propertyId, blockId]) => { - const latestValueBlock = ( - await groupBlock.children() - ).find((block: AsyncBlock) => block.id === blockId); + const blockHistory = ( + await Promise.all( + Object.entries(historyMap).map( + async ([propertyId, blockId]) => { + const latestValueBlock = ( + await groupBlock.children() + ).find((block: AsyncBlock) => block.id === blockId); - return getRecastItemValue(latestValueBlock).getValue( - propertyId as RecastPropertyId - ); - } + return getRecastItemValue( + latestValueBlock + ).getValue(propertyId as RecastPropertyId); + } + ) ) - ); - + ).filter(v => v); setHistory(blockHistory); }; + init(); - }, [getAllValue, getProperties, groupBlock, recastBlock]); + }, [block, getProperties, groupBlock, recastBlock]); return (