From 9e0e6fe4af8105f972a010e50259551a3dba96bf Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Thu, 14 Dec 2023 11:36:05 +0800 Subject: [PATCH 1/3] feat(capture-tab): show confirm dialog before refresh --- .../home/capture-tab/capture-tab.component.ts | 41 +++++++++++++------ src/assets/i18n/en-us.json | 4 ++ src/assets/i18n/zh-tw.json | 4 ++ 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/app/features/home/capture-tab/capture-tab.component.ts b/src/app/features/home/capture-tab/capture-tab.component.ts index 128ab9bd0..d0507eb6e 100644 --- a/src/app/features/home/capture-tab/capture-tab.component.ts +++ b/src/app/features/home/capture-tab/capture-tab.component.ts @@ -1,6 +1,7 @@ import { formatDate, KeyValue } from '@angular/common'; import { HttpErrorResponse } from '@angular/common/http'; import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { ActionSheetButton, @@ -15,7 +16,6 @@ import { catchError, concatMap, concatMapTo, - finalize, map, pluck, shareReplay, @@ -45,6 +45,7 @@ import { getOldProof } from '../../../shared/repositories/proof/old-proof-adapte import { Proof } from '../../../shared/repositories/proof/proof'; import { ProofRepository } from '../../../shared/repositories/proof/proof-repository.service'; import { reloadApp } from '../../../utils/miscellaneous'; +import { PrefetchingDialogComponent } from '../onboarding/prefetching-dialog/prefetching-dialog.component'; @UntilDestroy({ checkProperties: true }) @Component({ @@ -158,6 +159,8 @@ export class CaptureTabComponent implements OnInit { private readonly mediaStore: MediaStore, private readonly database: Database, private readonly confirmAlert: ConfirmAlert, + private readonly dialog: MatDialog, + private readonly preferenceManager: PreferenceManager, private readonly changeDetectorRef: ChangeDetectorRef, private readonly proofRepository: ProofRepository, @@ -334,17 +337,29 @@ export class CaptureTabComponent implements OnInit { return item.id; } - refreshCaptures(event: Event) { - this.diaBackendAssetRefreshingService - .refresh() - .pipe( - finalize(() => { - this.capturedTabPageIndex$.next(0); - this.collectedTabPageIndex$.next(0); - this.draftTabPageIndex$.next(0); - return (event).detail.complete(); - }) - ) - .subscribe(); + async refreshCaptures(event: Event) { + (event).detail.complete(); + + const confirmRefresh = await this.showRefreshAlert(); + if (confirmRefresh) { + this.capturedTabPageIndex$.next(0); + this.collectedTabPageIndex$.next(0); + this.draftTabPageIndex$.next(0); + + return this.dialog.open(PrefetchingDialogComponent, { + disableClose: true, + }); + } + } + + private async showRefreshAlert() { + return this.confirmAlert.present({ + header: this.translocoService.translate('syncAndRestore'), + message: this.translocoService.translate('message.confirmSyncAndRestore'), + confirmButtonText: this.translocoService.translate( + 'confirmSyncAndRestore' + ), + cancelButtonText: this.translocoService.translate('cancelSyncAndRestore'), + }); } } diff --git a/src/assets/i18n/en-us.json b/src/assets/i18n/en-us.json index bc36a6b2b..15fb98dbb 100644 --- a/src/assets/i18n/en-us.json +++ b/src/assets/i18n/en-us.json @@ -86,6 +86,9 @@ "restorePhotos": "Restore Captures", "restore": "Restore", "skip": "Skip", + "syncAndRestore": "Sync and restore all assets?", + "confirmSyncAndRestore": "Confirm", + "cancelSyncAndRestore": "Do it later", "contactUs": "Contact us", "editUsername": "Edit Username", "forgotPassword": "Forgot Password", @@ -169,6 +172,7 @@ "networkNotConnected": "No internet connections.", "allPhotosRegistered": "All Captures registered on blockchain successfully", "confirmPrefetch": "Do you want to restore the registered Captures? It may take minutes to complete.", + "confirmSyncAndRestore": "This will download all assets again and making sure your local data is up to date", "loadingPreviousData": "Restoring Captures...", "doNotTurnOffApp": "Please keep the screen on and DO NOT leave the app.", "upgrading": "Upgrading...", diff --git a/src/assets/i18n/zh-tw.json b/src/assets/i18n/zh-tw.json index 532117fd2..5d5c69f56 100644 --- a/src/assets/i18n/zh-tw.json +++ b/src/assets/i18n/zh-tw.json @@ -86,6 +86,9 @@ "restorePhotos": "恢復已註冊的瞬時影像", "restore": "恢復", "skip": "跳過", + "syncAndRestore": "同步並還原所有資產?", + "confirmSyncAndRestore": "確認", + "cancelSyncAndRestore": "稍後再說", "contactUs": "聯絡我們", "editUsername": "修改使用者名稱", "forgotPassword": "忘記密碼", @@ -169,6 +172,7 @@ "networkNotConnected": "沒有網路連線", "allPhotosRegistered": "所有瞬時影像都已成功註冊", "confirmPrefetch": "是否要恢復已註冊的瞬時影像?這個流程需要數分鐘的時間。", + "confirmSyncAndRestore": "這將重新下載所有資產,並確保您的本地數據是最新的。", "loadingPreviousData": "正在恢復已註冊的瞬時影像...", "doNotTurnOffApp": "載入中,期間請勿關閉螢幕與離開 APP。", "upgrading": "升級中...", From 33f17356f51f270b51faa40878ac4fd0af34902c Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Thu, 14 Dec 2023 15:17:07 +0800 Subject: [PATCH 2/3] fix(zh-tw): syncAndRestore --- src/assets/i18n/zh-tw.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/i18n/zh-tw.json b/src/assets/i18n/zh-tw.json index 5d5c69f56..6a673b905 100644 --- a/src/assets/i18n/zh-tw.json +++ b/src/assets/i18n/zh-tw.json @@ -86,7 +86,7 @@ "restorePhotos": "恢復已註冊的瞬時影像", "restore": "恢復", "skip": "跳過", - "syncAndRestore": "同步並還原所有資產?", + "syncAndRestore": "遠端同步並還原所有資產?", "confirmSyncAndRestore": "確認", "cancelSyncAndRestore": "稍後再說", "contactUs": "聯絡我們", From c7176114c2dcbf0bb2deaa935a71c94fc16cf29a Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Thu, 14 Dec 2023 15:20:22 +0800 Subject: [PATCH 3/3] fix(en-us): confirmSyncAndRestore --- src/assets/i18n/en-us.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/i18n/en-us.json b/src/assets/i18n/en-us.json index 15fb98dbb..c1a437662 100644 --- a/src/assets/i18n/en-us.json +++ b/src/assets/i18n/en-us.json @@ -172,7 +172,7 @@ "networkNotConnected": "No internet connections.", "allPhotosRegistered": "All Captures registered on blockchain successfully", "confirmPrefetch": "Do you want to restore the registered Captures? It may take minutes to complete.", - "confirmSyncAndRestore": "This will download all assets again and making sure your local data is up to date", + "confirmSyncAndRestore": "This will download all assets and making sure your local data is up to date", "loadingPreviousData": "Restoring Captures...", "doNotTurnOffApp": "Please keep the screen on and DO NOT leave the app.", "upgrading": "Upgrading...",