Avoid double omits whilst filtering current state

Change-type: patch
This commit is contained in:
Pagan Gazzard 2021-05-06 10:38:24 +00:00
parent 9a3596c44c
commit 466ff58871
2 changed files with 13 additions and 11 deletions

View File

@ -108,18 +108,18 @@ const getStateDiff = (): DeviceStatus => {
}
const diff = {
local: _(stateForReport.local)
.omitBy((val, key: keyof DeviceStatus['local']) =>
local: _.omitBy(
stateForReport.local,
(val, key: keyof NonNullable<DeviceStatus['local']>) =>
INTERNAL_STATE_KEYS.includes(key) ||
_.isEqual(lastReportedLocal[key], val),
)
.omit(INTERNAL_STATE_KEYS)
.value(),
dependent: _(stateForReport.dependent)
.omitBy((val, key: keyof DeviceStatus['dependent']) =>
),
dependent: _.omitBy(
stateForReport.dependent,
(val, key: keyof DeviceStatus['dependent']) =>
INTERNAL_STATE_KEYS.includes(key) ||
_.isEqual(lastReportedDependent[key], val),
)
.omit(INTERNAL_STATE_KEYS)
.value(),
),
};
const toOmit: string[] = sysInfo.filterNonSignificantChanges(

View File

@ -40,7 +40,9 @@ export interface DeviceStatus {
};
} & DeviceReportFields;
// TODO: Type the dependent entry correctly
dependent?: any;
dependent?: {
[key: string]: any;
};
commit?: string;
}