Skip to content

Commit

Permalink
Merge pull request #1373 from thebiggive/DON-904-timer-tidy
Browse files Browse the repository at this point in the history
DON-904 - tweak new My Account timeout
  • Loading branch information
NoelLH authored Nov 4, 2023
2 parents 043461c + 11039de commit 1e64a2d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/meta-campaign/meta-campaign.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class MetaCampaignComponent implements AfterViewChecked, OnDestroy, OnIni

ngOnDestroy() {
if (isPlatformBrowser(this.platformId) && this.tickerUpdateTimer) {
clearInterval(this.tickerUpdateTimer);
clearTimeout(this.tickerUpdateTimer);
}

if (this.routeChangeListener) {
Expand Down
19 changes: 15 additions & 4 deletions src/app/my-account/my-account.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
import {PageMetaService} from '../page-meta.service';
import {DatePipe} from '@angular/common';
import {DatePipe, isPlatformBrowser} from '@angular/common';
import {IdentityService} from "../identity.service";
import {Person} from "../person.model";
import {Router} from "@angular/router";
Expand All @@ -17,19 +17,22 @@ import {HttpErrorResponse} from "@angular/common/http";
styleUrls: ['./my-account.component.scss'],
providers: [DatePipe]
})
export class MyAccountComponent implements OnInit {
export class MyAccountComponent implements OnDestroy, OnInit {
public person: Person;

public paymentMethods: PaymentMethod[]|undefined = undefined;
registerErrorDescription: string | undefined;
registerSucessMessage: string | undefined;
protected readonly faExclamationTriangle = faExclamationTriangle;

private savedCardsTimer: undefined | ReturnType<typeof setTimeout>; // https://stackoverflow.com/a/56239226

constructor(
private pageMeta: PageMetaService,
public dialog: MatDialog,
private identityService: IdentityService,
private donationService: DonationService,
@Inject(PLATFORM_ID) private platformId: Object,
private router: Router,
) {
this.identityService = identityService;
Expand All @@ -48,10 +51,18 @@ export class MyAccountComponent implements OnInit {
} else {
this.person = person;
this.loadPaymentMethods();

if (isPlatformBrowser(this.platformId)) {
this.savedCardsTimer = setTimeout(this.checkForPaymentCardsIfNotLoaded, 5_000);
}
}
});
}

setTimeout(this.checkForPaymentCardsIfNotLoaded, 5_000);
ngOnDestroy() {
if (isPlatformBrowser(this.platformId) && this.savedCardsTimer) {
clearTimeout(this.savedCardsTimer);
}
}

loadPaymentMethods() {
Expand Down

0 comments on commit 1e64a2d

Please sign in to comment.