Skip to content

Commit f4e02d4

Browse files
Only store data version if the readCache changed (project-chip#33466)
* Only store data version if the readCache changed * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 3186155 commit f4e02d4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+4-2
Original file line numberDiff line numberDiff line change
@@ -2534,8 +2534,6 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
25342534
NSNumber * dataVersion = attributeDataValue[MTRDataVersionKey];
25352535
MTRClusterPath * clusterPath = [MTRClusterPath clusterPathWithEndpointID:attributePath.endpoint clusterID:attributePath.cluster];
25362536
if (dataVersion) {
2537-
[self _noteDataVersion:dataVersion forClusterPath:clusterPath];
2538-
25392537
// Remove data version from what we cache in memory
25402538
attributeDataValue = [self _dataValueWithoutDataVersion:attributeDataValue];
25412539
}
@@ -2544,6 +2542,10 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
25442542
BOOL readCacheValueChanged = ![self _attributeDataValue:attributeDataValue isEqualToDataValue:previousValue];
25452543
// Now that we have grabbed previousValue, update our cache with the attribute value.
25462544
if (readCacheValueChanged) {
2545+
if (dataVersion) {
2546+
[self _noteDataVersion:dataVersion forClusterPath:clusterPath];
2547+
}
2548+
25472549
[self _setCachedAttributeValue:attributeDataValue forPath:attributePath];
25482550
if (!_deviceConfigurationChanged) {
25492551
_deviceConfigurationChanged = [self _attributeAffectsDeviceConfiguration:attributePath];

0 commit comments

Comments
 (0)