fix badge warning total count

pull/3838/head
Joseph Izang 1 year ago
parent 3b4f8b9036
commit 76d77c17a4
  1. 14
      apps/remix-ide/src/app/tabs/analysis-tab.js

@ -58,18 +58,22 @@ class AnalysisTab extends ViewPlugin {
this.event.register('staticAnaysisWarning', (count) => { this.event.register('staticAnaysisWarning', (count) => {
let payloadType = '' let payloadType = ''
this.hints.forEach(hint => { let totalCount = 0
this.hints && this.hints.length > 0 ? this.hints.forEach(hint => {
if (hint.type === 'error') { if (hint.type === 'error') {
payloadType = 'error' payloadType = 'error'
} else if (hint.type === 'warning' && payloadType !== 'error') { } else if (hint.type === 'warning' && payloadType !== 'error') {
payloadType = 'warning' payloadType = 'warning'
} }
}) }) : payloadType = 'warning'
if (count > 0 && this.hints.length > 0) { if (count > 0) {
const totalCount = count === this.hints.length ? count : count + this.hints.length 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 }) 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' }) this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' })
} else { } else {
// count ==-1 no compilation result // count ==-1 no compilation result

Loading…
Cancel
Save