Skip to content

Commit

Permalink
When importing endpoint types the custom clusters were missing their …
Browse files Browse the repository at this point in the history
…package ids. Adding them here makes sure that their correct state is picked up during the import (project-chip#1334)

JIRA: ZAPP-1432
  • Loading branch information
brdandu authored Jun 4, 2024
1 parent 851ac0b commit 1cc9343
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src-electron/importexport/import-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,14 @@ function sortEndpoints(endpoints) {
*/
async function importClusters(db, allZclPackageIds, endpointTypeId, clusters) {
let relevantZclPackageIds = allZclPackageIds
// Get all custom xml packages since they will be relevant packages as well.
let packageInfo = await queryPackage.getPackagesByPackageIds(
db,
allZclPackageIds
)
let customPackageInfo = packageInfo.filter(
(pkg) => pkg.type === dbEnum.packageType.zclXmlStandalone
)
let endpointTypeDeviceTypesInfo =
await queryDeviceType.selectDeviceTypesByEndpointTypeId(db, endpointTypeId)
let deviceTypeRefs = endpointTypeDeviceTypesInfo.map(
Expand All @@ -421,7 +429,13 @@ async function importClusters(db, allZclPackageIds, endpointTypeId, clusters) {
db,
deviceTypeRefs[0]
)
relevantZclPackageIds = deviceTypeInfo.packageRef
relevantZclPackageIds = [deviceTypeInfo.packageRef]

// If custom packages exist then account for them during import.
if (customPackageInfo && customPackageInfo.length > 0) {
let customPackageInfoIds = customPackageInfo.map((cp) => cp.id)
relevantZclPackageIds = relevantZclPackageIds.concat(customPackageInfoIds)
}
}
if (clusters) {
for (let k = 0; k < clusters.length; k++) {
Expand Down Expand Up @@ -1762,7 +1776,7 @@ async function jsonDataLoader(

if ('endpointTypes' in state) {
const allZclPackageIds = []
allZclPackageIds.push(mainPackageData.zclPackageIds)
allZclPackageIds.push(...mainPackageData.zclPackageIds)
allZclPackageIds.push(...existingCustomXmlPackageIds)
allZclPackageIds.push(...newlyLoadedCustomPackageIds)
promisesStage1.push(
Expand Down

0 comments on commit 1cc9343

Please sign in to comment.