Skip to content

Commit

Permalink
fix error when minilinks soooo faster
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Aug 22, 2023
1 parent 43b49ab commit 49d528f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion imports/client-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function ClientHandler(_props: ClientHandlerProps) {

const [Component, setComponent] = React.useState<any>(null);

console.log('ClientHandler root', { linkId, handlerId, context, file, hid, files, Component });
// console.log('ClientHandler root', { linkId, handlerId, context, file, hid, files, Component });
const lastEvalRef = useRef(0);
useEffect(() => {
if (!hid) return;
Expand Down
9 changes: 5 additions & 4 deletions imports/cyto/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,17 @@ export function useLinkReactElements(elements = [], reactElements = [], cy, ml)
const [linkReactElements, setLinkReactElements] = useState<{ [key: string]: boolean }>({});
const linkReactElementsIds = useMemo(() => Object.keys(linkReactElements).filter(key => !!linkReactElements[key]), [linkReactElements]).map(key => parseInt(key), [linkReactElements]);

reactElements.push(...linkReactElementsIds.map(id => (elements.find(e => e.id === id))));
reactElements.push(...linkReactElementsIds.map(id => (elements.find(e => e.id === id))).filter(i => !!i));

const cyRef = useRefAutofill(cy);
const { open, close, isOpened } = useOpenedMethods();
const [spaceId] = useSpaceId();
const { data: Opened } = useDeepId('@deep-foundation/deepcase-opened', 'Opened');
reactElements.push(...(deep.minilinks?.byId?.[spaceId]?.outByType?.[Opened] || [])?.map(l => elements.find(e => e.id === l.to_id)));

reactElements.push(...((deep.minilinks?.byId?.[spaceId]?.outByType?.[Opened] || [])?.map(l => elements.find(e => e.id === l.to_id))).filter(i => !!i));

useEffect(() => {
if (cy) {
if (cy && Opened) {
const opened = cy?.$(`.deepcase-opened`);
opened.forEach(o => {
const isMustBeOpen = !!reactElements?.find(e => e === +o.id());
Expand All @@ -457,7 +458,7 @@ export function useLinkReactElements(elements = [], reactElements = [], cy, ml)
}
});
}
}, [reactElements]);
}, [reactElements, Opened]);

const toggleLinkReactElement = async (id: number) => {
const cy = cyRef.current;
Expand Down

0 comments on commit 49d528f

Please sign in to comment.