Skip to content

Commit

Permalink
fix: contact us page can't be used twice (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
Carola Bratsch authored Oct 28, 2021
1 parent fa1d321 commit 41eae48
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/app/pages/contact/contact-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { ActivationEnd, NavigationEnd, Router } from '@angular/router';
import { Observable, Subject } from 'rxjs';
import { debounce, filter, takeUntil } from 'rxjs/operators';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';

import { AccountFacade } from 'ish-core/facades/account.facade';
import { Contact } from 'ish-core/models/contact/contact.model';
Expand All @@ -22,24 +21,11 @@ export class ContactPageComponent implements OnInit, OnDestroy {
*/
success$: Observable<boolean>;

private destroy$ = new Subject();

constructor(private accountFacade: AccountFacade, private router: Router) {}

ngOnInit() {
this.loading$ = this.accountFacade.contactLoading$;
this.success$ = this.accountFacade.contactSuccess$;

// reset contact page if the user routes to 'contact' again after a contact form submission
this.router.events
.pipe(
filter(event => event instanceof ActivationEnd && !event.snapshot.queryParamMap.has('submitted')),
debounce(() => this.router.events.pipe(filter(event => event instanceof NavigationEnd))),
takeUntil(this.destroy$)
)
.subscribe(() => {
this.accountFacade.resetContactState();
});
}

/** dispatch contact request */
Expand All @@ -49,7 +35,7 @@ export class ContactPageComponent implements OnInit, OnDestroy {
}

ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
// reset contact page if the user routes to 'contact' again
this.accountFacade.resetContactState();
}
}

0 comments on commit 41eae48

Please sign in to comment.