Skip to content

Commit

Permalink
landing page chain filter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
manishiwa committed Mar 8, 2024
1 parent 2144a81 commit dc8e548
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions components/home/LandingUserBaseChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Heading from "@/components/layout/Heading";
import Subheading from "@/components/layout/Subheading";
import useSWR from "swr";
import { MasterResponse } from "@/types/api/MasterResponse";
import { AllChains, AllChainsByKeys } from "@/lib/chains";
import { AllChains, AllChainsByKeys, Get_SupportedChainKeys } from "@/lib/chains";
import { LandingPageMetricsResponse } from "@/types/api/LandingPageMetricsResponse";
import LandingChart from "@/components/layout/LandingChart";
import LandingMetricsTable from "@/components/layout/LandingMetricsTable";
Expand Down Expand Up @@ -69,13 +69,13 @@ export default function LandingUserBaseChart() {
}, [data, landing, selectedMetric, selectedTimeInterval]);

const chains = useMemo(() => {
if (!data) return [];
if (!data || !master) return [];

return AllChains.filter(
(chain) =>
Object.keys(data.chains).includes(chain.key) && chain.key != "ethereum",
Object.keys(data.chains).includes(chain.key) && Get_SupportedChainKeys(master) && chain.key != "ethereum",
);
}, [data]);
}, [data, master]);

const [selectedChains, setSelectedChains] = useState(
AllChains.map((chain) => chain.key),
Expand Down Expand Up @@ -104,6 +104,7 @@ export default function LandingUserBaseChart() {
data: data.chains[chain].data.data,
};
})}
master={master}
sources={landing.data.metrics.user_base.source}
cross_chain_users={data.cross_chain_users}
cross_chain_users_comparison={data.cross_chain_users_comparison}
Expand Down
10 changes: 7 additions & 3 deletions components/layout/LandingChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useLocalStorage, useSessionStorage } from "usehooks-ts";
import { useTheme } from "next-themes";
import { debounce, merge } from "lodash";
import { Switch } from "../Switch";
import { AllChainsByKeys, EnabledChainsByKeys } from "@/lib/chains";
import { AllChainsByKeys, EnabledChainsByKeys, Get_SupportedChainKeys } from "@/lib/chains";
import d3 from "d3";
import { Icon } from "@iconify/react";
import { Tooltip, TooltipContent, TooltipTrigger } from "./Tooltip";
Expand Down Expand Up @@ -184,6 +184,7 @@ const baseOptions: Highcharts.Options = {

export default function LandingChart({
data,
master,
cross_chain_users,
cross_chain_users_comparison,
latest_total,
Expand All @@ -199,6 +200,7 @@ export default function LandingChart({
// showTimeIntervals = true,
{
data: any;
master: any;
cross_chain_users: number;
cross_chain_users_comparison: number;
latest_total: number;
Expand Down Expand Up @@ -616,6 +618,8 @@ export default function LandingChart({

const tooltipFormatter = useCallback(
function (this: any) {
if (!master)
return;
const { x, points } = this;
const date = new Date(x);
const dateString = `
Expand Down Expand Up @@ -675,7 +679,7 @@ export default function LandingChart({
const { series, y, percentage } = point;
const { name } = series;

return Object.keys(EnabledChainsByKeys).includes(name);
return Object.keys(Get_SupportedChainKeys(master)).includes(name);
})
.map((point: any) => {
const { series, y, percentage } = point;
Expand Down Expand Up @@ -733,7 +737,7 @@ export default function LandingChart({

return tooltip + tooltipPoints + tooltipEnd;
},
[formatNumber, selectedMetric, selectedScale, theme],
[formatNumber, selectedMetric, selectedScale, theme, master],
);

const tooltipPositioner =
Expand Down

0 comments on commit dc8e548

Please sign in to comment.