Skip to content

Commit

Permalink
fix(visualizator-fe): Fix date filter not working 🛠️
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldev5 authored and dudo50 committed Dec 4, 2024
1 parent d52c61e commit 73622dd
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import { useMemo, useRef } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import type { ChannelsQuery, TotalMessageCountsQuery } from '../../gql/graphql';
import { CountOption } from '../../gql/graphql';
import Relaychain from '../Relaychain/Relaychain';
Expand Down Expand Up @@ -34,6 +34,8 @@ const ParachainsGraph: FC<Props> = ({ channels, totalMessageCounts, ecosystem })
toggleActiveEditParachain
} = useSelectedParachain();

const [refsInitialized, setRefsInitialized] = useState(false);

const groupRef = useRef<Group>(null);

const sortedParachainNames = useMemo(() => {
Expand Down Expand Up @@ -103,6 +105,16 @@ const ParachainsGraph: FC<Props> = ({ channels, totalMessageCounts, ecosystem })

const relaychainRef = useRef<Group | null>(null);

useEffect(() => {
const relaychainReady = relaychainRef.current !== null;

const allParachainsReady = Object.values(parachainRefs.current).every(ref => ref !== null);

if (relaychainReady && allParachainsReady) {
setRefsInitialized(true);
}
}, [parachainRefs, relaychainRef]);

return (
<group name={ecosystem} ref={groupRef}>
<Relaychain
Expand All @@ -129,6 +141,7 @@ const ParachainsGraph: FC<Props> = ({ channels, totalMessageCounts, ecosystem })

{/* Channels */}
{ecosystem === Ecosystem.POLKADOT &&
refsInitialized &&
channels.map(channel => {
const senderKey =
channel.sender === RELAYCHAIN_ID
Expand Down

0 comments on commit 73622dd

Please sign in to comment.