Skip to content

Commit

Permalink
Defensive localstorage + fix console error
Browse files Browse the repository at this point in the history
  • Loading branch information
MinThaMie committed Nov 9, 2023
1 parent 20da981 commit de84afb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/routes/bingo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import Route from '@ember/routing/route';
import { tracked } from 'tracked-built-ins';

const completedCells = JSON.parse(localStorage.getItem('completed')) ?? [];
let completedCells = [];

try {
completedCells = JSON.parse(localStorage.getItem('completed')) ?? [];
} catch (e) {
localStorage.setItem('completed', []);
}

const cells = [
{
Expand Down
2 changes: 1 addition & 1 deletion app/templates/bingo.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<dialog>
<p id="modal-description"></p>
<button type="button" class="button button-secondary" {{on 'click' this.hideModal}}>I'll come back</button>
<button type="button" class="button" {{on 'click' this.completeSquare}}>Add to my roles</button>
<button type="button" class="button complete" {{on 'click' this.completeSquare}}>Add to my roles</button>
</dialog>
<div class="callout">
<h2>How to</h2>
Expand Down

0 comments on commit de84afb

Please sign in to comment.