Skip to content

Commit

Permalink
[wip] apps scrolling hist
Browse files Browse the repository at this point in the history
  • Loading branch information
manishiwa committed Feb 20, 2025
1 parent 996dbd2 commit 2682e85
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/(layout)/applications/[owner_project]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Icon } from "@iconify/react";
import VerticalVirtuosoScrollContainer from "@/components/VerticalVirtuosoScrollContainer";
import Link from "next/link";
import { SortProvider, useSort } from "../_contexts/SortContext";
import { useUIContext } from "@/contexts/UIContext";
import { useHighchartsWrappers, useUIContext } from "@/contexts/UIContext";
import { GTPIconName } from "@/icons/gtp-icon-names";
import { Virtuoso } from "react-virtuoso";
import { useRouter } from "next/navigation";
Expand Down Expand Up @@ -100,6 +100,8 @@ const MetricSection = ({ metric, owner_project }: { metric: string; owner_projec
const { selectedTimespan } = useTimespan();
const [showUsd, setShowUsd] = useLocalStorage("showUsd", true);

useHighchartsWrappers();

const def = metricsDef[metric];

// create a list of the chain keys sorted by the aggregate value for the selected timespan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const ApplicationsDataProvider = ({ children }: { children: React.ReactNo
// create new url
let url = `${pathname}?${decodeURIComponent(searchParams.toString())}`;

router.push(url, {scroll: false});
router.replace(url, {scroll: false});
};
/* </ Query Params > */

Expand Down
2 changes: 1 addition & 1 deletion app/(layout)/applications/_contexts/TimespanContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const TimespanProvider = ({ children, timespans, defaultTimespan = "7d" }
let url = `${pathname}?${decodeURIComponent(searchParams.toString())}`;

// update query params
router.push(url, {scroll: false});
router.replace(url, {scroll: false});
};
/* </ Query Params > */

Expand Down
10 changes: 10 additions & 0 deletions app/(layout)/applications/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ export default function Page() {
return () => window.removeEventListener('scroll', handleScroll);
}, []);

useEffect(() => {
const referrer = document.referrer;
if (referrer.includes("/applications/")) {
const savedScrollPos = sessionStorage.getItem('applicationsScrollPos');
if (savedScrollPos) {
window.scrollTo(0, Number(savedScrollPos));
}
}
}, []);

const { topGainers, topLosers } = useMemo(() => {
// let medianMetricKey = Object.keys(metricsDef).includes(sort.metric) ? sort.metric : "gas_fees";

Expand Down

0 comments on commit 2682e85

Please sign in to comment.