@@ -3,6 +3,7 @@ import { RemoteI18n } from '../../i18n/RemoteI18n';
33import { accountDeviceDisplayName, CloudAccountDevice } from '../../services/CloudAccountClient';
44import { AccountDeviceSelectionPolicy } from '../policy/AccountDeviceSelectionPolicy';
55import { DeviceModelSettingsEntryPolicy } from '../policy/DeviceModelSettingsEntryPolicy';
6+ import { DeviceDirectoryEntry, DeviceDirectoryState } from '../state/DeviceDirectoryState';
67import {
78 CARD,
89 CONTENT_ON_ACTION,
@@ -20,6 +21,7 @@ import { DefaultAccountAvatar } from './DefaultAccountAvatar';
2021/** Account identity and device management shared by Settings and account entry. */
2122@ComponentV2
2223export struct AccountProfilePanel {
24+ @Param directoryState: DeviceDirectoryState = new DeviceDirectoryState();
2325 @Param accountUsername: string = '';
2426 @Param accountAvatarUrl: string = '';
2527 @Param accountUserId: string = '';
@@ -42,7 +44,6 @@ export struct AccountProfilePanel {
4244 async (): Promise<CloudAccountDevice[]> => [];
4345 @Event cloudSelectDevice: (device: CloudAccountDevice) => Promise<void> =
4446 async (_device: CloudAccountDevice): Promise<void> => {};
45- @Local accountDevices: CloudAccountDevice[] = [];
4647 @Local accountDevicesBusy: boolean = false;
4748 @Local accountDevicesError: string = '';
4849 @Local switchingDeviceId: string = '';
@@ -172,7 +173,7 @@ export struct AccountProfilePanel {
172173 if (!this.isAccountAuthenticated()) {
173174 Text(RemoteI18n.t('remote.settings.deviceLoginRequired'))
174175 .fontSize(MobileDesignTypography.bodySmall.size).lineHeight(MobileDesignTypography.bodySmall.lineHeight).fontColor(MUTED).width('100%')
175- } else if (this.accountDevicesBusy && this.accountDevices .length === 0) {
176+ } else if (this.accountDevicesBusy && this.directoryState.devices .length === 0) {
176177 Text(RemoteI18n.t('remote.settings.deviceLoading'))
177178 .fontSize(MobileDesignTypography.bodySmall.size).fontColor(MUTED).width('100%')
178179 } else if (this.desktopDevices().length === 0) {
@@ -349,7 +350,7 @@ export struct AccountProfilePanel {
349350 this.accountDevicesBusy = true;
350351 this.accountDevicesError = '';
351352 try {
352- this.accountDevices = await this.cloudListDevices();
353+ await this.cloudListDevices();
353354 } catch (err) {
354355 this.accountDevicesError = err instanceof Error ? err.message :
355356 RemoteI18n.t('remote.settings.deviceLoadFailed');
@@ -358,8 +359,8 @@ export struct AccountProfilePanel {
358359 }
359360 }
360361
361- private desktopDevices(): CloudAccountDevice [] {
362- return this.accountDevices. filter((device: CloudAccountDevice ): boolean =>
362+ private desktopDevices(): DeviceDirectoryEntry [] {
363+ return this.directoryState.devices. filter((device: DeviceDirectoryEntry ): boolean =>
363364 device.deviceId !== this.deviceId && device.deviceName !== 'HarmonyOS Phone');
364365 }
365366
@@ -488,7 +489,7 @@ export struct AccountProfilePanel {
488489
489490 @Monitor('accountUserId')
490491 private handleAccountUserChanged(): void {
491- if (this.isAccountAuthenticated() && this.accountDevices .length === 0) {
492+ if (this.isAccountAuthenticated() && this.directoryState.devices .length === 0) {
492493 this.refreshAccountDevices();
493494 }
494495 }
0 commit comments