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

View File

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