From 44120ac70595c6dbdfb24b580607df5872db400a Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Fri, 7 Feb 2025 15:56:19 +1030 Subject: [PATCH] fix: persist format card description/condition visibility in local storage --- frontend/src/components/format/FormatCard.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/format/FormatCard.jsx b/frontend/src/components/format/FormatCard.jsx index a2703b2..0f1b9ba 100644 --- a/frontend/src/components/format/FormatCard.jsx +++ b/frontend/src/components/format/FormatCard.jsx @@ -14,7 +14,10 @@ function FormatCard({ willBeSelected, onSelect }) { - const [showDescription, setShowDescription] = useState(true); + const [showDescription, setShowDescription] = useState(() => { + const saved = localStorage.getItem(`format-view-${format.file_name}`); + return saved !== null ? JSON.parse(saved) : true; + }); const {content} = format; const totalTests = content.tests?.length || 0; const passedTests = content.tests?.filter(t => t.passes)?.length || 0; @@ -45,7 +48,14 @@ function FormatCard({ const handleViewToggle = e => { e.stopPropagation(); - setShowDescription(!showDescription); + setShowDescription(prev => { + const newState = !prev; + localStorage.setItem( + `format-view-${format.file_name}`, + JSON.stringify(newState) + ); + return newState; + }); }; const handleMouseDown = e => {