From 4f0151542fbfb30c9a37df4063293d4ac0bcc027 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 2 Nov 2026 12:33:46 +0200 Subject: [PATCH] fix(iot-hub): check the update again after any way back, check default converters in parallel and keep the latest run --- .../device-install-dialog.component.ts | 20 ++++++--- ...iot-hub-installed-items-table.component.ts | 41 ++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts index ca92919b5b..54dfc3e218 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts @@ -555,6 +555,15 @@ export class TbDeviceInstallDialogComponent extends DialogComponent this.resetUpdatePlan(ws)); + } return; } // Forward moves can come from the stepper header, which bypasses nextStep(), diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts index a99fc65a66..2677ec1cbe 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts @@ -74,6 +74,7 @@ export class TbIotHubInstalledItemsTableComponent implements OnInit, OnChanges, publishedVersionMap = new Map(); // Installed device packages whose default converter differs from ThingsBoard's default converter now converterUpdates = new Set(); + private converterCheckRun = 0; updatesChecked = false; isCheckingUpdates = false; @@ -277,35 +278,47 @@ export class TbIotHubInstalledItemsTableComponent implements OnInit, OnChanges, * ThingsBoard's default converter now. ThingsBoard's default changes with ThingsBoard, so the package has no new version for it. */ private async checkConverterUpdates(): Promise { - const updates = new Set(); + // A later load (another page, sort or search) starts another run: an earlier one finishing last mustn't win + const run = ++this.converterCheckRun; + // The package's default converter of each DEVICE package on the page + const checks: { itemId: string; converterId: string }[] = []; // Over all installed packages, not only this page's, as the update dialog decides let ownDefaultConverterIds: Set | undefined; for (const item of this.dataSource) { const states = item.itemType === 'DEVICE' ? Object.values((item.descriptor as DeviceInstalledItemDescriptor)?.installState ?? {}) : []; for (const state of states) { - let id: string = state?.defaultConverter ? state.entityOutput?.id : undefined; + const id: string = state?.defaultConverter ? state.entityOutput?.id : undefined; + if (!id) { + continue; + } // A converter taken as it was counts only when a package installed it as its default converter - if (id && state.resolution === 'use-existing') { + if (state.resolution === 'use-existing') { ownDefaultConverterIds ??= await loadOwnDefaultConverterIds(this.iotHubApiService); if (!ownDefaultConverterIds.has(id)) { - id = undefined; - } - } - const converter = id ? await firstValueFrom(this.converterService.getConverter(id, {ignoreErrors: true, ignoreLoading: true})) - .catch(() => null) : null; - if (converter) { - const defaultConverter = await loadDefaultUplinkConverter(this.resourcesService, converter.integrationType, - converter.configuration.scriptLang, converter.name); - if (defaultConverter && differsFromDefaultConverter(converter, defaultConverter)) { - updates.add(item.id.id); + continue; } } + checks.push({ itemId: item.id.id, converterId: id }); } } - this.converterUpdates = updates; + const changed = await Promise.all(checks.map(async ({ itemId, converterId }) => { + const converter = await firstValueFrom(this.converterService.getConverter(converterId, {ignoreErrors: true, ignoreLoading: true})) + .catch(() => null); + if (!converter) { + return null; + } + const defaultConverter = await loadDefaultUplinkConverter(this.resourcesService, converter.integrationType, + converter.configuration.scriptLang, converter.name); + return defaultConverter && differsFromDefaultConverter(converter, defaultConverter) ? itemId : null; + })); + if (run !== this.converterCheckRun) { + return; + } + this.converterUpdates = new Set(changed.filter(itemId => !!itemId)); this.cd.markForCheck(); } + getPublishedVersionInfo(item: IotHubInstalledItem): ItemPublishedVersionInfo | undefined { return this.publishedVersionMap.get(item.itemId); }