Skip to content
Snippets Groups Projects
Commit 7d22a565 authored by Albert Bruns's avatar Albert Bruns
Browse files

OZG-7773 poc mail timing issue

parent 3891200d
No related branches found
No related tags found
2 merge requests!122OZG-7773-Nachrichten-auf-ungelesen-setzen-e2e,!120OZG-7773-Nachrichten-auf-ungelesen-setzen
...@@ -31,7 +31,7 @@ import { ...@@ -31,7 +31,7 @@ import {
isDone, isDone,
isPending, isPending,
} from '@alfa-client/command-shared'; } from '@alfa-client/command-shared';
import { NavigationService } from '@alfa-client/navigation-shared'; import { NavigationFacade, NavigationService, RouteData } from '@alfa-client/navigation-shared';
import { import {
createEmptyStateResource, createEmptyStateResource,
createStateResource, createStateResource,
...@@ -42,14 +42,14 @@ import { ...@@ -42,14 +42,14 @@ import {
StateResource, StateResource,
} from '@alfa-client/tech-shared'; } from '@alfa-client/tech-shared';
import { SnackBarService } from '@alfa-client/ui'; import { SnackBarService } from '@alfa-client/ui';
import { VorgangResource, VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { getVorgangParam, VorgangResource, VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { inject, Injectable } from '@angular/core'; import { inject, Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Params } from '@angular/router'; import { Params } from '@angular/router';
import { hasLink, Resource } from '@ngxp/rest'; import { hasLink, Resource } from '@ngxp/rest';
import { isNil, isNull } from 'lodash-es'; import { isNil, isNull } from 'lodash-es';
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs'; import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
import { first, map, take, tap } from 'rxjs/operators'; import { first, map, switchMap, take, tap } from 'rxjs/operators';
import { PostfachFacade } from './+state/postfach.facade'; import { PostfachFacade } from './+state/postfach.facade';
import { PostfachMailLinkRel, PostfachMailListLinkRel } from './postfach.linkrel'; import { PostfachMailLinkRel, PostfachMailListLinkRel } from './postfach.linkrel';
import { PostfachMessages } from './postfach.message'; import { PostfachMessages } from './postfach.message';
...@@ -74,6 +74,7 @@ export class PostfachService { ...@@ -74,6 +74,7 @@ export class PostfachService {
private readonly dialog = inject(MatDialog); private readonly dialog = inject(MatDialog);
private readonly postfachFacade = inject(PostfachFacade); private readonly postfachFacade = inject(PostfachFacade);
private readonly binaryFileService = inject(BinaryFileService); private readonly binaryFileService = inject(BinaryFileService);
private readonly navigationFacade = inject(NavigationFacade);
private readonly isPollSendPostachMail: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false); private readonly isPollSendPostachMail: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
postfachMailList$: BehaviorSubject<StateResource<PostfachMailListResource>> = new BehaviorSubject< postfachMailList$: BehaviorSubject<StateResource<PostfachMailListResource>> = new BehaviorSubject<
...@@ -216,14 +217,42 @@ export class PostfachService { ...@@ -216,14 +217,42 @@ export class PostfachService {
}); });
} }
_doResetHasNewPostfachNachrichten(): void { navigateToPostfach(): void {
this._doResetHasNewPostfachNachrichten(true);
}
_doResetHasNewPostfachNachrichten(navigate: boolean = false): void {
if (hasLink(this.postfachMailList$.value.resource, PostfachMailListLinkRel.RESET_HAS_NEW_POSTFACH_NACHRICHT)) { if (hasLink(this.postfachMailList$.value.resource, PostfachMailListLinkRel.RESET_HAS_NEW_POSTFACH_NACHRICHT)) {
this.repository.resetHasNewPostfachNachrichten(this.postfachMailList$.value.resource).pipe(take(1)).subscribe(); this.repository
.resetHasNewPostfachNachrichten(this.postfachMailList$.value.resource)
.pipe(take(1))
.subscribe(() => {
if (navigate) this._navigateToPostfach();
});
} else {
if (navigate) this._navigateToPostfach();
} }
} }
_navigateToPostfach(): void {
this.navigationFacade
.getCurrentRouteData()
.pipe(take(1))
.subscribe((currenRoute: RouteData) => {
this.navigationService.navigateToPostfach(getVorgangParam(currenRoute));
});
}
public setHasNewPostfachNachrichten() { public setHasNewPostfachNachrichten() {
this.repository.setHasNewPostfachNachrichten(this.postfachMailList$.value.resource).pipe(take(1)).subscribe(); this.repository
.setHasNewPostfachNachrichten(this.postfachMailList$.value.resource)
.pipe(
switchMap(() => this.navigationFacade.getCurrentRouteData()),
take(1),
)
.subscribe((currenRoute: RouteData) => {
this.navigationService.navigateToVorgang(getVorgangParam(currenRoute));
});
} }
_pollSendPostfachMailCommand(command: StateResource<CommandResource>): StateResource<CommandResource> { _pollSendPostfachMailCommand(command: StateResource<CommandResource>): StateResource<CommandResource> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment