fixed: when remove all tag, editor will throw error in tag history popover, fixed #20
This commit is contained in:
@@ -26,7 +26,6 @@ export const PendantHistoryPanel = ({
|
|||||||
const { getProperties } = useRecastBlockMeta();
|
const { getProperties } = useRecastBlockMeta();
|
||||||
const { getProperty } = useRecastBlockMeta();
|
const { getProperty } = useRecastBlockMeta();
|
||||||
|
|
||||||
const { getAllValue } = getRecastItemValue(block);
|
|
||||||
const recastBlock = useRecastBlock();
|
const recastBlock = useRecastBlock();
|
||||||
|
|
||||||
const [history, setHistory] = useState<RecastBlockValue[]>([]);
|
const [history, setHistory] = useState<RecastBlockValue[]>([]);
|
||||||
@@ -34,7 +33,7 @@ export const PendantHistoryPanel = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
const currentBlockValues = getAllValue();
|
const currentBlockValues = getRecastItemValue(block).getAllValue();
|
||||||
const allProperties = getProperties();
|
const allProperties = getProperties();
|
||||||
const missProperties = allProperties.filter(
|
const missProperties = allProperties.filter(
|
||||||
property => !currentBlockValues.find(v => v.id === property.id)
|
property => !currentBlockValues.find(v => v.id === property.id)
|
||||||
@@ -52,24 +51,26 @@ export const PendantHistoryPanel = ({
|
|||||||
return history;
|
return history;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const blockHistory = await Promise.all(
|
const blockHistory = (
|
||||||
|
await Promise.all(
|
||||||
Object.entries(historyMap).map(
|
Object.entries(historyMap).map(
|
||||||
async ([propertyId, blockId]) => {
|
async ([propertyId, blockId]) => {
|
||||||
const latestValueBlock = (
|
const latestValueBlock = (
|
||||||
await groupBlock.children()
|
await groupBlock.children()
|
||||||
).find((block: AsyncBlock) => block.id === blockId);
|
).find((block: AsyncBlock) => block.id === blockId);
|
||||||
|
|
||||||
return getRecastItemValue(latestValueBlock).getValue(
|
return getRecastItemValue(
|
||||||
propertyId as RecastPropertyId
|
latestValueBlock
|
||||||
);
|
).getValue(propertyId as RecastPropertyId);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
|
).filter(v => v);
|
||||||
setHistory(blockHistory);
|
setHistory(blockHistory);
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}, [getAllValue, getProperties, groupBlock, recastBlock]);
|
}, [block, getProperties, groupBlock, recastBlock]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledPendantHistoryPanel>
|
<StyledPendantHistoryPanel>
|
||||||
|
|||||||
Reference in New Issue
Block a user