From 18b9683d4e4460aee5c0da303b971978fb8ae747 Mon Sep 17 00:00:00 2001 From: Olga Shen Date: Tue, 16 Apr 2024 18:40:08 +0800 Subject: [PATCH] feat(app/features): remove view asset profile Remove "View asset profile" and move "Share Asset Profile" to the first option in the detail share menu. --- src/app/features/home/details/details.page.ts | 79 +++---------------- .../dia-backend-asset-repository.service.ts | 24 ------ src/assets/i18n/en-us.json | 1 - src/assets/i18n/zh-tw.json | 1 - 4 files changed, 13 insertions(+), 92 deletions(-) diff --git a/src/app/features/home/details/details.page.ts b/src/app/features/home/details/details.page.ts index bbbef6d0a..6fac0f2f9 100644 --- a/src/app/features/home/details/details.page.ts +++ b/src/app/features/home/details/details.page.ts @@ -44,7 +44,6 @@ import { isNonNullable, switchTap, } from '../../../utils/rx-operators/rx-operators'; -import { getAssetProfileForNSE } from '../../../utils/url'; import { DetailedCapture, InformationSessionService, @@ -192,15 +191,6 @@ export class DetailsPage { map(type => type === 'post-capture') ); - readonly activeDetailedCaptureTmpShareToken$ = - this._activeDetailedCapture$.pipe( - distinctUntilChanged(), - concatMap(({ id }) => { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return this.diaBackendAssetRepository.createTemporaryShareToken$(id!); - }) - ); - userToken: string | undefined; readonly isFromSeriesPage$ = this.type$.pipe(map(type => type === 'series')); @@ -320,14 +310,9 @@ export class DetailsPage { openShareMenu() { combineLatest([ - this.activeDetailedCapture$, this.activeDetailedCapture$.pipe(switchMap(c => c.diaBackendAsset$)), - this.activeDetailedCapture$.pipe( - switchMap(c => c.postCreationWorkflowCompleted$) - ), this.capAppWebCryptoApiSignatureProvider.publicKey$, this.translocoService.selectTranslateObject({ - 'message.viewAssetProfile': null, 'message.copyIpfsAddress': null, 'message.shareAssetProfile': null, }), @@ -336,38 +321,12 @@ export class DetailsPage { first(), concatMap( ([ - detailedCapture, diaBackendAsset, - postCreationWorkflowCompleted, publicKey, - [ - messageviewAssetProfile, - messageCopyIpfsAddress, - messageShareAssetProfile, - ], + [messageCopyIpfsAddress, messageShareAssetProfile], ]) => new Promise(resolve => { const buttons: ActionSheetButton[] = []; - if (postCreationWorkflowCompleted && detailedCapture.id) { - buttons.push({ - text: messageviewAssetProfile, - handler: () => { - this.openCertificate(); - resolve(); - }, - }); - } - if (diaBackendAsset?.cid) { - buttons.push({ - text: messageCopyIpfsAddress, - handler: () => { - const ipfsAddress = `https://ipfs-pin.numbersprotocol.io/ipfs/${diaBackendAsset.cid}`; - this.copyToClipboard(ipfsAddress); - resolve(); - }, - }); - } - if ( diaBackendAsset?.owner_addresses.asset_wallet_address === publicKey @@ -388,6 +347,18 @@ export class DetailsPage { }, }); } + + if (diaBackendAsset?.cid) { + buttons.push({ + text: messageCopyIpfsAddress, + handler: () => { + const ipfsAddress = `https://ipfs-pin.numbersprotocol.io/ipfs/${diaBackendAsset.cid}`; + this.copyToClipboard(ipfsAddress); + resolve(); + }, + }); + } + this.actionSheetController .create({ buttons }) .then(sheet => sheet.present()); @@ -719,30 +690,6 @@ export class DetailsPage { .subscribe(); } - openCertificate() { - combineLatest([ - this.activeDetailedCapture$, - this.activeDetailedCaptureTmpShareToken$, - ]) - .pipe( - first(), - concatMap(([detailedCapture, tmpShareToken]) => - defer(() => - Browser.open({ - url: getAssetProfileForNSE( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - detailedCapture.id!, - tmpShareToken - ), - toolbarColor: '#564dfc', - }) - ) - ), - untilDestroyed(this) - ) - .subscribe(); - } - private openCaptureClub() { combineLatest([ this.activeDetailedCapture$.pipe( diff --git a/src/app/shared/dia-backend/asset/dia-backend-asset-repository.service.ts b/src/app/shared/dia-backend/asset/dia-backend-asset-repository.service.ts index 766f69af0..21b303b63 100644 --- a/src/app/shared/dia-backend/asset/dia-backend-asset-repository.service.ts +++ b/src/app/shared/dia-backend/asset/dia-backend-asset-repository.service.ts @@ -260,22 +260,6 @@ export class DiaBackendAssetRepository { ); } - createTemporaryShareToken$(id: string) { - const formData = new FormData(); - const secondsInDay = 86400; - formData.append('expiration_seconds', `${secondsInDay}`); - return defer(() => this.authService.getAuthHeaders()).pipe( - concatMap(headers => - this.httpClient.post( - `${BASE_URL}/api/v3/assets/${id}/private-share/`, - formData, - { headers } - ) - ), - map(response => response.tmp_token) - ); - } - removeCaptureById$(id: string) { return defer(() => this.authService.getAuthHeaders()).pipe( concatMap(headers => @@ -373,14 +357,6 @@ export type AssetDownloadField = type CreateAssetResponse = DiaBackendAsset; type UpdateAssetResponse = DiaBackendAsset; -export interface CreateTmpShareTokenResponse extends Tuple { - tmp_token: string; - url: string; - expiration_seconds: number; - created_at: string; - expired_at: string; -} - // eslint-disable-next-line @typescript-eslint/no-empty-interface interface DeleteAssetResponse {} diff --git a/src/assets/i18n/en-us.json b/src/assets/i18n/en-us.json index ba37dba41..7d5126fa7 100644 --- a/src/assets/i18n/en-us.json +++ b/src/assets/i18n/en-us.json @@ -180,7 +180,6 @@ "transferOwnership": "Transfer ownership", "deregisterFromNetwork": "Deregister from network", "viewOnCaptureClub": "View on CaptureClub", - "viewAssetProfile": "View asset profile", "confirmDelete": "Your local data will be wiped out after deletion. Please double-check that you have created a backup and understand the risk.", "confirmLogout": "Your local data will be wipe out after logout. You can restore your Captures after login again.", "resetPasswordEnterEmail": "To reset the password, you have to enter your registered email.", diff --git a/src/assets/i18n/zh-tw.json b/src/assets/i18n/zh-tw.json index 04a145f67..c472bf8f8 100644 --- a/src/assets/i18n/zh-tw.json +++ b/src/assets/i18n/zh-tw.json @@ -180,7 +180,6 @@ "transferOwnership": "轉移影像所有權", "deregisterFromNetwork": "刪除並從影像網絡註銷", "viewOnCaptureClub": "在 CaptureClub 檢視", - "viewAssetProfile": "檢視資產檔案", "confirmDelete": "所有您的本地資料將會在刪除帳號後清除。請再次確認您已備份資料並了解其中的風險。", "confirmLogout": "所有您的本地資料將會在登出後清除。再次登入後可以復原您的拍攝。", "resetPasswordEnterEmail": "請輸入您的註冊信箱以重新設定密碼。",