Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app/features): remove view asset profile #3241

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 13 additions & 66 deletions src/app/features/home/details/details.page.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@
"transferOwnership": "轉移影像所有權",
"deregisterFromNetwork": "刪除並從影像網絡註銷",
"viewOnCaptureClub": "在 CaptureClub 檢視",
"viewAssetProfile": "檢視資產檔案",
"confirmDelete": "所有您的本地資料將會在刪除帳號後清除。請再次確認您已備份資料並了解其中的風險。",
"confirmLogout": "所有您的本地資料將會在登出後清除。再次登入後可以復原您的拍攝。",
"resetPasswordEnterEmail": "請輸入您的註冊信箱以重新設定密碼。",
Expand Down
Loading