handle possible null case for dep error

This commit is contained in:
Matt Hill
2021-09-30 22:01:16 -06:00
committed by Aiden McClelland
parent 8c6fab319a
commit eaafc764f5
3 changed files with 6 additions and 5 deletions

View File

@@ -207,7 +207,7 @@ export class AppShowPage {
let actionText = 'View'
let action: () => any = () => this.navCtrl.navigateForward(`/services/${id}`)
const error = this.pkg.installed.status['dependency-errors'][id] || null
const error = this.pkg.installed.status['dependency-errors'][id]
if (error) {
// health checks failed

View File

@@ -224,7 +224,7 @@ export interface Action {
export interface Status {
configured: boolean
main: MainStatus
'dependency-errors': { [id: string]: DependencyError }
'dependency-errors': { [id: string]: DependencyError | null }
}
export type MainStatus = MainStatusStopped | MainStatusStopping | MainStatusRunning | MainStatusBackingUp | MainStatusRestoring

View File

@@ -33,15 +33,16 @@ function getDependencyStatus (pkg: PackageDataEntry): DependencyStatus {
const installed = pkg.installed
if (isEmptyObject(installed['current-dependencies'])) return null
const pkgIds = Object.keys(installed.status['dependency-errors'])
const depErrors = installed.status['dependency-errors']
const depIds = Object.keys(depErrors).filter(key => !!depErrors[key])
for (let pkgId of pkgIds) {
for (let pkgId of depIds) {
if (pkg.manifest.dependencies[pkgId].critical) {
return DependencyStatus.Critical
}
}
return pkgIds.length ? DependencyStatus.Issue : DependencyStatus.Satisfied
return depIds.length ? DependencyStatus.Issue : DependencyStatus.Satisfied
}
function getHealthStatus (status: Status): HealthStatus {