Skip to content

Commit

Permalink
fix(global): disable overview click event
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Nov 21, 2024
1 parent 722ec67 commit 753c7de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
3 changes: 0 additions & 3 deletions app/(main)/ClientComponents/ServerListClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ export default function ServerListClient() {
<section className="flex items-center gap-2 w-full overflow-hidden">
<button
onClick={() => {
setStatus("all");
setFilter(false);
sessionStorage.removeItem("selectedTag");
router.push(`/?global=true`);
}}
className="rounded-[50px] bg-stone-100 p-[10px] transition-all hover:bg-stone-200 dark:hover:bg-stone-700 dark:bg-stone-800"
Expand Down
21 changes: 16 additions & 5 deletions app/(main)/ClientComponents/ServerOverviewClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ export default function ServerOverviewClient() {
<section className="grid grid-cols-2 gap-4 lg:grid-cols-4">
<Card
onClick={() => {
setFilter(false);
if (!global) {
setFilter(false);
setStatus("all");
}
}}
className="cursor-pointer hover:border-blue-500 transition-all"
className={cn("cursor-pointer hover:border-blue-500 transition-all", {
"pointer-events-none": global,
})}
>
<CardContent className="px-6 py-3">
<section className="flex flex-col gap-1">
Expand All @@ -74,8 +76,8 @@ export default function ServerOverviewClient() {
</Card>
<Card
onClick={() => {
setFilter(false);
if (!global) {
setFilter(false);
setStatus("online");
}
}}
Expand All @@ -84,6 +86,9 @@ export default function ServerOverviewClient() {
{
"ring-green-500 ring-2 border-transparent": status === "online",
},
{
"pointer-events-none": global,
},
)}
>
<CardContent className="px-6 py-3">
Expand Down Expand Up @@ -111,8 +116,8 @@ export default function ServerOverviewClient() {
</Card>
<Card
onClick={() => {
setFilter(false);
if (!global) {
setFilter(false);
setStatus("offline");
}
}}
Expand All @@ -121,6 +126,9 @@ export default function ServerOverviewClient() {
{
"ring-red-500 ring-2 border-transparent": status === "offline",
},
{
"pointer-events-none": global,
},
)}
>
<CardContent className="px-6 py-3">
Expand Down Expand Up @@ -148,8 +156,8 @@ export default function ServerOverviewClient() {
</Card>
<Card
onClick={() => {
setStatus("all");
if (!global) {
setStatus("all");
setFilter(true);
}
}}
Expand All @@ -158,6 +166,9 @@ export default function ServerOverviewClient() {
{
"ring-purple-500 ring-2 border-transparent": filter === true,
},
{
"pointer-events-none": global,
},
)}
>
<CardContent className="relative px-6 py-3">
Expand Down
7 changes: 7 additions & 0 deletions components/GlobalBackButton.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
"use client";

import { useFilter } from "@/lib/network-filter-context";
import { useStatus } from "@/lib/status-context";
import { ServerStackIcon } from "@heroicons/react/20/solid";
import { useRouter } from "next/navigation";
import { useEffect } from "react";

export default function GlobalBackButton() {
const router = useRouter();
const { setStatus } = useStatus();
const { setFilter } = useFilter();

useEffect(() => {
setStatus("all");
setFilter(false);
sessionStorage.removeItem("selectedTag");
router.prefetch(`/`);
}, []);

Expand Down

0 comments on commit 753c7de

Please sign in to comment.