From 76d77c17a435858d20e180d3f6454ad3dce02fb9 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 22 Jun 2023 22:42:06 +0100 Subject: [PATCH] fix badge warning total count --- apps/remix-ide/src/app/tabs/analysis-tab.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/analysis-tab.js b/apps/remix-ide/src/app/tabs/analysis-tab.js index 0d3add88f5..e4df06e423 100644 --- a/apps/remix-ide/src/app/tabs/analysis-tab.js +++ b/apps/remix-ide/src/app/tabs/analysis-tab.js @@ -58,18 +58,22 @@ class AnalysisTab extends ViewPlugin { this.event.register('staticAnaysisWarning', (count) => { let payloadType = '' - this.hints.forEach(hint => { + let totalCount = 0 + this.hints && this.hints.length > 0 ? this.hints.forEach(hint => { if (hint.type === 'error') { payloadType = 'error' } else if (hint.type === 'warning' && payloadType !== 'error') { payloadType = 'warning' } - }) + }) : payloadType = 'warning' - if (count > 0 && this.hints.length > 0) { - const totalCount = count === this.hints.length ? count : count + this.hints.length + if (count > 0) { + if (this.hints && this.hints.length > 0) { + totalCount = count === this.hints.length ? count : count + this.hints.length + } + totalCount += count this.emit('statusChanged', { key: totalCount, title: `${totalCount} warning${totalCount === 1 ? '' : 's'}`, type: payloadType }) - } else if (count === 0 && this.hints.length === 0) { + } else if (count === 0) { this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' }) } else { // count ==-1 no compilation result