Skip to content

Commit

Permalink
Add fallback handling if localStorage not available
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzipp committed Jun 7, 2024
1 parent 6bf6d64 commit 3497c60
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/entries/contentScript/components/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function Card({
const [isExpanded, setIsExpanded] = useState(false);

function getExpandedCards() {
if (!localStorage) {
return [];
}

const lsExpandedCardsValue = localStorage.getItem(LOCALSTORAGE_KEY);

if (lsExpandedCardsValue) {
Expand All @@ -51,6 +55,10 @@ function Card({
function toggleExpanded() {
setIsExpanded(!isExpanded);

if (!localStorage) {
return;
}

if (id) {
let lsExpandedCards = getExpandedCards();

Expand Down

0 comments on commit 3497c60

Please sign in to comment.