Skip to content

Commit

Permalink
Merge pull request #3253 from numbersprotocol/feature-parent-asset-pr…
Browse files Browse the repository at this point in the history
…ofile

feat(features/home): link asset profile to parent
  • Loading branch information
olgahaha authored Sep 20, 2024
2 parents 8ecba1c + c0b9166 commit c69cf22
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute } from '@angular/router';
import { Plugins } from '@capacitor/core';
import { Clipboard } from '@capacitor/clipboard';
import { NavController } from '@ionic/angular';
import { TranslocoService } from '@ngneat/transloco';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
Expand All @@ -21,9 +21,7 @@ import { ErrorService } from '../../../../shared/error/error.service';
import { BubbleToIonicPostMessage } from '../../../../shared/iframe/iframe';
import { NetworkService } from '../../../../shared/network/network.service';
import { isNonNullable } from '../../../../utils/rx-operators/rx-operators';
import { getAssetProfileForNSE } from '../../../../utils/url';

const { Browser, Clipboard } = Plugins;
@UntilDestroy({ checkProperties: true })
@Component({
selector: 'app-network-action-order-details',
Expand Down Expand Up @@ -125,18 +123,6 @@ export class NetworkActionOrderDetailsPage {
.subscribe();
}

// eslint-disable-next-line class-methods-use-this
openResultUrl(url: string) {
if (url) {
Browser.open({ url, toolbarColor: '#000000' });
}
}

// eslint-disable-next-line class-methods-use-this
resultUrlFromAssetId(assetId: string) {
return getAssetProfileForNSE(assetId);
}

async copyToClipboard(value: string) {
await Clipboard.write({ string: value });
this.snackBar.open(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ export class CaptureDetailsWithIonicComponent {
defer(() =>
Browser.open({
url: getAssetProfileForNSE(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
detailedCapture.id!
/* eslint-disable-next-line
@typescript-eslint/no-non-null-assertion,
@typescript-eslint/prefer-nullish-coalescing
*/
detailedCapture.parentAssetCid || detailedCapture.id!
),
toolbarColor: browserToolbarColor,
})
Expand Down
4 changes: 3 additions & 1 deletion src/app/features/home/details/details.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ export class DetailsPage {
buttons.push({
text: viewProofText,
handler: async () => {
await this.handleOpenProofAction(diaBackendAsset.id);
await this.handleOpenProofAction(
diaBackendAsset.parent_asset_cid || diaBackendAsset.id
);
resolve();
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export class DetailedCapture {
? getOldProof(this.proofOrDiaBackendAsset).hash
: this.proofOrDiaBackendAsset.proof_hash;

readonly parentAssetCid =
this.proofOrDiaBackendAsset instanceof Proof
? this.proofOrDiaBackendAsset.parentAssetCid
: this.proofOrDiaBackendAsset.parent_asset_cid;

readonly mediaUrl$ = defer(() => {
if (this.proofOrDiaBackendAsset instanceof Proof) {
const proof = this.proofOrDiaBackendAsset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export interface DiaBackendAsset extends Tuple {
readonly mint_workflow_id: string;
readonly uploaded_at: string;
readonly public_access: boolean;
readonly parent_asset_cid: string;
}

export interface OwnerAddresses extends Tuple {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class DiaBackendAssetDownloadingService {
proof.diaBackendAssetId = diaBackendAsset.id;
proof.caption = diaBackendAsset.caption;
proof.uploadedAt = diaBackendAsset.uploaded_at;
proof.parentAssetCid = diaBackendAsset.parent_asset_cid;
if (diaBackendAsset.signed_metadata) proof.setSignatureVersion();
return this.proofRepository.add(proof, OnConflictStrategy.REPLACE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class DiaBackendAssetUploadingService {
map(diaBackendAsset => {
proof.diaBackendAssetId = diaBackendAsset.id;
proof.uploadedAt = diaBackendAsset.uploaded_at;
proof.parentAssetCid = diaBackendAsset.parent_asset_cid;
return proof;
}),
retryWhen(err$ =>
Expand Down
5 changes: 5 additions & 0 deletions src/app/shared/repositories/proof/proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export class Proof {

integritySha?: string = undefined;

parentAssetCid?: string = undefined;

/**
* Since capture cam originally capture photos/videos from camera we set cameraSource to
* CameraSource.Camera by default. If user picks photo/video from galley then cameraSource
Expand Down Expand Up @@ -164,6 +166,7 @@ export class Proof {
proof.isCollected = indexedProofView.isCollected ?? false;
proof.signatureVersion = indexedProofView.signatureVersion;
proof.integritySha = indexedProofView.integritySha;
proof.parentAssetCid = indexedProofView.parentAssetCid;
proof.cameraSource = indexedProofView.cameraSource;
return proof;
}
Expand Down Expand Up @@ -335,6 +338,7 @@ export class Proof {
uploadedAt: this.uploadedAt,
isCollected: this.isCollected,
integritySha: this.integritySha,
parentAssetCid: this.parentAssetCid,
cameraSource: this.cameraSource,
};
}
Expand Down Expand Up @@ -471,6 +475,7 @@ export interface IndexedProofView extends Tuple {
readonly uploadedAt?: string;
readonly isCollected?: boolean;
readonly integritySha?: string;
readonly parentAssetCid?: string;
readonly cameraSource: CameraSource;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/share/share.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ShareService {
.pipe(catchError((err: unknown) => this.errorService.toastError$(err)))
.toPromise();
}
return getAssetProfileForNSE(asset.id);
return getAssetProfileForNSE(asset.parent_asset_cid || asset.id);
}

async shareReferralCode(referralCode: string) {
Expand Down

0 comments on commit c69cf22

Please sign in to comment.