Skip to content

Commit 0224c26

Browse files
committed
Revert "Merge pull request #3157 from numbersprotocol/fix-excessive-api-call"
This reverts commit d9b5652, reversing changes made to 064e7cf.
1 parent d3c2cea commit 0224c26

File tree

4 files changed

+9
-51
lines changed

4 files changed

+9
-51
lines changed

src/app/features/home/capture-tab/capture-item/capture-item.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export class CaptureItemComponent {
7171
)
7272
);
7373

74-
readonly hasCaption$ = this.proof$.pipe(map(proof => proof.caption !== ''));
74+
readonly hasCaption$ = this.proof$.pipe(
75+
switchMap(proof => this.diaBackendAssetRepository.fetchByProof$(proof)),
76+
map(asset => asset.caption !== '')
77+
);
7578

7679
readonly isVideo$ = this.proof$.pipe(
7780
concatMap(proof => proof.getFirstAssetMeta()),

src/app/features/home/details/edit-caption/edit-caption.page.ts

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@ import { DomSanitizer } from '@angular/platform-browser';
33
import { ActivatedRoute } from '@angular/router';
44
import { NavController } from '@ionic/angular';
55
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
6-
import { combineLatest, fromEvent, of } from 'rxjs';
7-
import {
8-
concatMap,
9-
finalize,
10-
first,
11-
map,
12-
tap as switchTap,
13-
} from 'rxjs/operators';
6+
import { combineLatest, fromEvent } from 'rxjs';
7+
import { map, tap } from 'rxjs/operators';
148
import { DiaBackendAuthService } from '../../../../shared/dia-backend/auth/dia-backend-auth.service';
159
import { BUBBLE_IFRAME_URL } from '../../../../shared/dia-backend/secret';
1610
import { BubbleToIonicPostMessage } from '../../../../shared/iframe/iframe';
1711
import { IframeService } from '../../../../shared/iframe/iframe.service';
18-
import { getOldProof } from '../../../../shared/repositories/proof/old-proof-adapter';
19-
import { ProofRepository } from '../../../../shared/repositories/proof/proof-repository.service';
2012
import { isNonNullable } from '../../../../utils/rx-operators/rx-operators';
21-
import { InformationSessionService } from '../information/session/information-session.service';
2213

2314
@UntilDestroy()
2415
@Component({
@@ -52,17 +43,15 @@ export class EditCaptionPage {
5243
private readonly sanitizer: DomSanitizer,
5344
private readonly navController: NavController,
5445
private readonly iframeService: IframeService,
55-
private readonly diaBackendAuthService: DiaBackendAuthService,
56-
private readonly informationSessionService: InformationSessionService,
57-
private readonly proofRepository: ProofRepository
46+
private readonly diaBackendAuthService: DiaBackendAuthService
5847
) {
5948
this.processIframeEvents();
6049
}
6150

6251
processIframeEvents() {
6352
fromEvent(window, 'message')
6453
.pipe(
65-
switchTap(event => {
54+
tap(event => {
6655
const postMessageEvent = event as MessageEvent;
6756
const data = postMessageEvent.data as BubbleToIonicPostMessage;
6857
switch (data) {
@@ -71,36 +60,12 @@ export class EditCaptionPage {
7160
break;
7261
case BubbleToIonicPostMessage.EDIT_CAPTION_SAVE:
7362
this.iframeService.refreshDetailsPageIframe();
74-
this.syncCaptionAndNavigateBack();
63+
this.navController.back();
7564
break;
7665
}
7766
}),
7867
untilDestroyed(this)
7968
)
8069
.subscribe();
8170
}
82-
83-
syncCaptionAndNavigateBack() {
84-
if (this.informationSessionService.activatedDetailedCapture) {
85-
combineLatest([
86-
this.informationSessionService.activatedDetailedCapture.proof$,
87-
this.informationSessionService.activatedDetailedCapture.caption$,
88-
])
89-
.pipe(
90-
first(),
91-
concatMap(([proof, latestCaptionFromBackend]) => {
92-
if (proof) {
93-
proof.caption = latestCaptionFromBackend;
94-
return this.proofRepository.update(
95-
[proof],
96-
(x, y) => getOldProof(x).hash === getOldProof(y).hash
97-
);
98-
}
99-
return of(null);
100-
}),
101-
finalize(() => this.navController.back())
102-
)
103-
.subscribe();
104-
}
105-
}
10671
}

src/app/shared/dia-backend/asset/downloading/dia-backend-downloading.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export class DiaBackendAssetDownloadingService {
8080
},
8181
});
8282
proof.diaBackendAssetId = diaBackendAsset.id;
83-
proof.caption = diaBackendAsset.caption;
8483
if (diaBackendAsset.signed_metadata) proof.setSignatureVersion();
8584
return this.proofRepository.add(proof, OnConflictStrategy.REPLACE);
8685
}

src/app/shared/repositories/proof/proof.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ export class Proof {
2626

2727
diaBackendAssetId?: string = undefined;
2828

29-
/**
30-
* When user uploades a capture we do not have option to set caption. Therefore caption is empty
31-
* by default. Everytime caption is updated we need to update the caption in the proof as well.
32-
*/
33-
caption = '';
34-
3529
isCollected = false;
3630

3731
signatures: Signatures = {};
@@ -126,7 +120,6 @@ export class Proof {
126120
);
127121
proof.setIndexedAssets(indexedProofView.indexedAssets);
128122
proof.diaBackendAssetId = indexedProofView.diaBackendAssetId;
129-
proof.caption = indexedProofView.caption ?? '';
130123
proof.isCollected = indexedProofView.isCollected ?? false;
131124
proof.signatureVersion = indexedProofView.signatureVersion;
132125
proof.integritySha = indexedProofView.integritySha;
@@ -297,7 +290,6 @@ export class Proof {
297290
signatures: this.signatures,
298291
signatureVersion: this.signatureVersion,
299292
diaBackendAssetId: this.diaBackendAssetId,
300-
caption: this.caption,
301293
isCollected: this.isCollected,
302294
integritySha: this.integritySha,
303295
cameraSource: this.cameraSource,
@@ -432,7 +424,6 @@ export interface IndexedProofView extends Tuple {
432424
readonly signatures: Signatures;
433425
readonly signatureVersion?: string;
434426
readonly diaBackendAssetId?: string;
435-
readonly caption?: string;
436427
readonly isCollected?: boolean;
437428
readonly integritySha?: string;
438429
readonly cameraSource: CameraSource;

0 commit comments

Comments
 (0)