Skip to content

Commit

Permalink
feat(app/features): remove view asset profile
Browse files Browse the repository at this point in the history
Remove "View asset profile" and move "Share Asset Profile" to the first
option in the detail share menu.
  • Loading branch information
olgahaha committed Apr 16, 2024
1 parent 200e7c4 commit 18b9683
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 92 deletions.
79 changes: 13 additions & 66 deletions src/app/features/home/details/details.page.ts
Expand Up @@ -44,7 +44,6 @@ import {
isNonNullable,
switchTap,
} from '../../../utils/rx-operators/rx-operators';
import { getAssetProfileForNSE } from '../../../utils/url';
import {
DetailedCapture,
InformationSessionService,
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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,
}),
Expand All @@ -336,38 +321,12 @@ export class DetailsPage {
first(),
concatMap(
([
detailedCapture,
diaBackendAsset,
postCreationWorkflowCompleted,
publicKey,
[
messageviewAssetProfile,
messageCopyIpfsAddress,
messageShareAssetProfile,
],
[messageCopyIpfsAddress, messageShareAssetProfile],
]) =>
new Promise<void>(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
Expand All @@ -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());
Expand Down Expand Up @@ -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(
Expand Down
Expand Up @@ -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<CreateTmpShareTokenResponse>(
`${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 =>
Expand Down Expand Up @@ -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 {}

Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/en-us.json
Expand Up @@ -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.",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/zh-tw.json
Expand Up @@ -180,7 +180,6 @@
"transferOwnership": "轉移影像所有權",
"deregisterFromNetwork": "刪除並從影像網絡註銷",
"viewOnCaptureClub": "在 CaptureClub 檢視",
"viewAssetProfile": "檢視資產檔案",
"confirmDelete": "所有您的本地資料將會在刪除帳號後清除。請再次確認您已備份資料並了解其中的風險。",
"confirmLogout": "所有您的本地資料將會在登出後清除。再次登入後可以復原您的拍攝。",
"resetPasswordEnterEmail": "請輸入您的註冊信箱以重新設定密碼。",
Expand Down

0 comments on commit 18b9683

Please sign in to comment.