diff --git a/app.js b/app.js index c5d8016..1cfc8ca 100644 --- a/app.js +++ b/app.js @@ -341,7 +341,6 @@ async function removeMatch(id) { toggleLoading(true); try { - const match = state.matches.find(m => m.id === id); await deleteMatch(id); state.matches = state.matches.filter(m => m.id !== id); diff --git a/src/chart.js b/src/chart.js index ca2b539..14b5359 100644 --- a/src/chart.js +++ b/src/chart.js @@ -184,6 +184,10 @@ export function renderEloChart(type = 'singles') { .sort((a, b) => a[1].name.localeCompare(b[1].name)); if (activePlayers.length === 0) { + if (chartInstance) { + chartInstance.destroy(); + chartInstance = null; + } let msg = canvas.parentElement.querySelector('.chart-empty-msg'); if (!msg) { msg = document.createElement('p'); diff --git a/src/state.js b/src/state.js index 72d177d..147ab53 100644 --- a/src/state.js +++ b/src/state.js @@ -41,14 +41,26 @@ export function persistMatches() { export function loadLocalPlayers() { const raw = localStorage.getItem('eloPlayers'); - if (raw) state.players = JSON.parse(raw); - return !!raw; + if (!raw) return false; + try { + state.players = JSON.parse(raw); + return true; + } catch { + localStorage.removeItem('eloPlayers'); + return false; + } } export function loadLocalMatches() { const raw = localStorage.getItem('eloMatches'); - if (raw) state.matches = JSON.parse(raw); - return !!raw; + if (!raw) return false; + try { + state.matches = JSON.parse(raw); + return true; + } catch { + localStorage.removeItem('eloMatches'); + return false; + } } // ================= STATISTIK-NEUBERECHNUNG =================