From 204beadba6a98a4741ab8163048259cc1348805c Mon Sep 17 00:00:00 2001 From: liujuan Date: Sat, 1 Jun 2024 08:44:34 +0000 Subject: [PATCH 1/2] update product/phone/src/main/ets/view/PhotoBrowserComponent.ets. Signed-off-by: liujuan --- product/phone/src/main/ets/view/PhotoBrowserComponent.ets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/product/phone/src/main/ets/view/PhotoBrowserComponent.ets b/product/phone/src/main/ets/view/PhotoBrowserComponent.ets index 5af27b2d..f6b666df 100644 --- a/product/phone/src/main/ets/view/PhotoBrowserComponent.ets +++ b/product/phone/src/main/ets/view/PhotoBrowserComponent.ets @@ -600,7 +600,7 @@ export struct PhotoBrowserComponent { Log.info(TAG, 'onBackPress'); this.appBroadCast.emit('hideBar', []); let currentPhoto = this.getPhotoByIndex(this.currentIndex); - this.broadCast.emit(BrowserConstants.RESET_DEFAULT_SCALE + currentPhoto.uri, []); + this.broadCast.emit(BrowserConstants.RESET_DEFAULT_SCALE + currentPhoto?.uri, []); this.controller?.finishAnimation((): void => this.onBackPressInner()); return true; } @@ -668,7 +668,7 @@ export struct PhotoBrowserComponent { updatePhotoName(result: TitleName): void { let currentPhoto = this.getCurrentPhoto(); - currentPhoto.setTitle(result.title); + currentPhoto?.setTitle(result.title); currentPhoto.displayName = result.displayName; this.appBroadCast.emit(BroadCastConstants.UPDATE_DATA_SOURCE, [currentPhoto]); } @@ -1168,7 +1168,7 @@ export struct PhotoBrowserComponent { this.syncPhotoName(currentPhoto).then((result) => { if (result) { this.updatePhotoName(result); - this.broadCast.emit(PhotoConstants.UPDATE_PHOTO_NAME + currentPhoto.uri, [result.title]); + this.broadCast.emit(PhotoConstants.UPDATE_PHOTO_NAME + currentPhoto?.uri, [result.title]); } }); } @@ -1377,7 +1377,7 @@ export struct PhotoBrowserComponent { private async syncPhotoName(currentPhoto: MediaItem): Promise { Log.debug(TAG, 'syncPhotoName start'); let renameResult: TitleName = {title: '', displayName: ''}; - let fileAsset = await this.dataSource.getDataByUri(currentPhoto.uri); + let fileAsset = await this.dataSource?.getDataByUri(currentPhoto.uri); if (fileAsset) { renameResult = { title: fileAsset.get(UserFileManagerAccess.FILE_KEY_TITLE.toString()) as string, From 0b00905c3899acb59a65d6c1f87d8f3f9a8a4fcd Mon Sep 17 00:00:00 2001 From: liujuan Date: Sat, 1 Jun 2024 08:48:32 +0000 Subject: [PATCH 2/2] update product/phone/src/main/ets/view/PhotoBrowserComponent.ets. Signed-off-by: liujuan --- product/phone/src/main/ets/view/PhotoBrowserComponent.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product/phone/src/main/ets/view/PhotoBrowserComponent.ets b/product/phone/src/main/ets/view/PhotoBrowserComponent.ets index f6b666df..e843158a 100644 --- a/product/phone/src/main/ets/view/PhotoBrowserComponent.ets +++ b/product/phone/src/main/ets/view/PhotoBrowserComponent.ets @@ -1377,14 +1377,14 @@ export struct PhotoBrowserComponent { private async syncPhotoName(currentPhoto: MediaItem): Promise { Log.debug(TAG, 'syncPhotoName start'); let renameResult: TitleName = {title: '', displayName: ''}; - let fileAsset = await this.dataSource?.getDataByUri(currentPhoto.uri); + let fileAsset = await this.dataSource?.getDataByUri(currentPhoto?.uri); if (fileAsset) { renameResult = { title: fileAsset.get(UserFileManagerAccess.FILE_KEY_TITLE.toString()) as string, displayName: fileAsset.displayName }; } else { - let key: string = 'renameResult' + currentPhoto.uri; + let key: string = 'renameResult' + currentPhoto?.uri; renameResult = AppStorage.get(key) as TitleName; AppStorage.delete(key); }