@@ -3,22 +3,13 @@ import { DomSanitizer } from '@angular/platform-browser';
33import { ActivatedRoute } from '@angular/router' ;
44import { NavController } from '@ionic/angular' ;
55import { 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' ;
148import { DiaBackendAuthService } from '../../../../shared/dia-backend/auth/dia-backend-auth.service' ;
159import { BUBBLE_IFRAME_URL } from '../../../../shared/dia-backend/secret' ;
1610import { BubbleToIonicPostMessage } from '../../../../shared/iframe/iframe' ;
1711import { 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' ;
2012import { 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}
0 commit comments