Skip to content

Commit 367c543

Browse files
authored
fix( ANG-911 ): show merge/add toaster at once on login (#622)
1 parent c7a295d commit 367c543

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/app/app.component.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { createDispatchMap, select } from '@ngxs/store';
1+
import { Actions, createDispatchMap, ofActionSuccessful, select } from '@ngxs/store';
22

3-
import { filter } from 'rxjs';
3+
import { filter, take } from 'rxjs';
44

55
import { ChangeDetectionStrategy, Component, DestroyRef, effect, inject, OnInit } from '@angular/core';
66
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@@ -29,7 +29,7 @@ export class AppComponent implements OnInit {
2929
private readonly customDialogService = inject(CustomDialogService);
3030
private readonly router = inject(Router);
3131
private readonly environment = inject(ENVIRONMENT);
32-
32+
private readonly actions$ = inject(Actions);
3333
private readonly actions = createDispatchMap({ getCurrentUser: GetCurrentUser, getEmails: GetEmails });
3434

3535
unverifiedEmails = select(UserEmailsSelectors.getUnverifiedEmails);
@@ -44,7 +44,15 @@ export class AppComponent implements OnInit {
4444

4545
ngOnInit(): void {
4646
this.actions.getCurrentUser();
47-
this.actions.getEmails();
47+
48+
this.actions$
49+
.pipe(
50+
ofActionSuccessful(GetCurrentUser),
51+
take(1)
52+
)
53+
.subscribe(() => {
54+
this.actions.getEmails();
55+
});
4856

4957
if (this.environment.googleTagManagerId) {
5058
this.router.events

0 commit comments

Comments
 (0)