mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-17 14:56:36 +00:00
refactor(details): move panel cleanup logic into useEffect
This commit is contained in:
parent
ce4a0e64c9
commit
fbf563dfdf
@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useEffect } from "react";
|
||||
import { ArrowLeftIcon } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useProblem } from "@/hooks/use-problem";
|
||||
@ -15,14 +16,17 @@ export default function DetailsPage() {
|
||||
const { api, submission } = useDockviewStore();
|
||||
const { editorLanguageConfigs, problemId } = useProblem();
|
||||
|
||||
if (!api || !problemId || !submission?.id) return null;
|
||||
|
||||
if (problemId !== submission.problemId) {
|
||||
const detailsPanel = api.getPanel("Details");
|
||||
if (detailsPanel) {
|
||||
api.removePanel(detailsPanel);
|
||||
useEffect(() => {
|
||||
if (!api || !problemId || !submission?.id) return;
|
||||
if (problemId !== submission.problemId) {
|
||||
const detailsPanel = api.getPanel("Details");
|
||||
if (detailsPanel) {
|
||||
api.removePanel(detailsPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [api, problemId, submission])
|
||||
|
||||
if (!api || !problemId || !submission?.id) return null;
|
||||
|
||||
const createdAt = new Date(submission.createdAt);
|
||||
const submittedDisplay = isBefore(createdAt, subDays(new Date(), 1))
|
||||
|
Loading…
Reference in New Issue
Block a user