From 3b2808f0fd3f6a1cd71a9b01adc0aa45f68adfe5 Mon Sep 17 00:00:00 2001 From: Bobby Date: Thu, 6 Oct 2022 05:12:25 +0700 Subject: [PATCH] fix: failsafes for stats null values --- src/js/dashboard.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/dashboard.js b/src/js/dashboard.js index 1fed3b0..747fe51 100644 --- a/src/js/dashboard.js +++ b/src/js/dashboard.js @@ -3171,13 +3171,15 @@ page.getStatistics = (params = {}) => { } const data = response.data.stats[keys[i]][valKeys[j]] - const type = (typeof data === 'object' && data.type) || 'auto' + const isDataObj = typeof data === 'object' && data + + const type = (isDataObj && data.type) || 'auto' // Skip hidden if (type === 'hidden') { continue } - const value = typeof data === 'object' ? data.value : data + const value = isDataObj ? data.value : data let parsed = void 0 switch (type) { @@ -3243,7 +3245,7 @@ page.getStatistics = (params = {}) => { } let keyAttrs = '' - if (typeof data === 'object' && data.action) { + if (isDataObj && data.action) { keyAttrs += ` data-action="${data.action}"` if (data.actionData) { keyAttrs += ` data-action-data="${data.actionData}"`