Skip to content

Commit

Permalink
fix: toggling hide bots for yolo coders no longer causes page jumps (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline authored Aug 12, 2024
1 parent 33fc634 commit 4337ec3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pages/s/[org]/[repo]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HiOutlineExternalLink } from "react-icons/hi";
import { FaBalanceScale } from "react-icons/fa";
import { FaRegClock } from "react-icons/fa6";

import { useEffect, useMemo, useState } from "react";
import { useMemo, useState } from "react";
import dynamic from "next/dynamic";
import { useRouter } from "next/router";
import { usePostHog } from "posthog-js/react";
Expand Down Expand Up @@ -43,6 +43,7 @@ import RossChart from "components/Repositories/RossChart";
import YoloChart from "components/Repositories/YoloChart";
import LanguagePill, { getLanguageTopic } from "components/shared/LanguagePill/LanguagePill";
import OssfChart from "components/Repositories/OssfChart";
import { setQueryParams } from "lib/utils/query-params";

const AddToWorkspaceModal = dynamic(() => import("components/Repositories/AddToWorkspaceModal"), {
ssr: false,
Expand Down Expand Up @@ -96,19 +97,17 @@ export default function RepoPage({ repoData, ogImageUrl }: RepoPageProps) {
const isMobile = useMediaQuery("(max-width: 576px)");
const avatarUrl = getAvatarByUsername(repoData.full_name.split("/")[0], 96);
const [lotteryState, setLotteryState] = useState<"lottery" | "yolo">("lottery");
const [yoloHideBots, setYoloHideBots] = useState(
router.query.hideBots ? (router.query.hideBots === "true" ? true : false) : false
);
const yoloHideBots = router.query.hideBots === "true";
const [isAddToWorkspaceModalOpen, setIsAddToWorkspaceModalOpen] = useState(false);
const range = (router.query.range ? Number(router.query.range) : 30) as Range;
const tabList = [
{ name: "Overview", path: "" },
{ name: "Contributors", path: "contributors" },
];

useEffect(() => {
router.push({ query: { ...router.query, hideBots: yoloHideBots } });
}, [yoloHideBots]);
function setYoloHideBots(value: boolean) {
setQueryParams({ hideBots: `${value}` });
}

const {
data: starsData,
Expand Down

0 comments on commit 4337ec3

Please sign in to comment.