From c672fd95ecd7676ac36cdf4400b6ab849f236570 Mon Sep 17 00:00:00 2001 From: jjabari-op <122434454+jjabari-op@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:24:00 +0100 Subject: [PATCH] Bug/58787 notification banner is showing up on all pages (#17114) fix global instantiation of ian center state --- .../bell/in-app-notification-bell.component.ts | 11 ++++++++++- frontend/src/app/features/plugins/plugin-context.ts | 2 -- .../work-packages/activities-tab/index.controller.ts | 5 +---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts index 417a2534b2b1..180d9489f873 100644 --- a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts +++ b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, HostListener } from '@angular/core'; import { combineLatest, merge, Observable, timer } from 'rxjs'; import { filter, map, shareReplay, switchMap, throttleTime } from 'rxjs/operators'; import { ActiveWindowService } from 'core-app/core/active-window/active-window.service'; @@ -33,6 +33,15 @@ export class InAppNotificationBellComponent implements OnInit { populateInputsFromDataset(this); } + // enable other parts of the application to trigger an immediate update + // e.g. a stimulus controller + // currently used by the new activities tab which does it's own polling + // and receives updates from the backend earlier than the polling in the bell component + @HostListener('document:ian-update-immediate') + triggerImmediateUpdate() { + this.storeService.fetchUnread().subscribe(); + } + ngOnInit() { this.polling$ = merge( timer(10, this.interval).pipe(filter(() => this.activeWindow.isActive)), diff --git a/frontend/src/app/features/plugins/plugin-context.ts b/frontend/src/app/features/plugins/plugin-context.ts index 56550723912b..9153da3a8978 100644 --- a/frontend/src/app/features/plugins/plugin-context.ts +++ b/frontend/src/app/features/plugins/plugin-context.ts @@ -33,7 +33,6 @@ import { AttachmentsResourceService } from 'core-app/core/state/attachments/atta import { HttpClient } from '@angular/common/http'; import { TimezoneService } from 'core-app/core/datetime/timezone.service'; import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service'; -import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service'; /** * Plugin context bridge for plugins outside the CLI compiler context * in order to access services and parts of the core application @@ -69,7 +68,6 @@ export class OpenProjectPluginContext { attachmentsResourceService: this.injector.get(AttachmentsResourceService), http: this.injector.get(HttpClient), turboRequests: this.injector.get(TurboRequestsService), - ianCenter: this.injector.get(IanCenterService), }; public readonly helpers = { diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts index 51da16177367..f6cbe05bef8d 100644 --- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts +++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts @@ -4,7 +4,6 @@ import { } from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types'; import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service'; import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service'; -import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service'; interface CustomEventWithIdParam extends Event { params:{ @@ -56,13 +55,11 @@ export default class IndexController extends Controller { private turboRequests:TurboRequestsService; private apiV3Service:ApiV3Service; - private ianCenterService:IanCenterService; async connect() { const context = await window.OpenProject.getPluginContext(); this.turboRequests = context.services.turboRequests; this.apiV3Service = context.services.apiV3Service; - this.ianCenterService = context.services.ianCenter; this.setLocalStorageKey(); this.setLastUpdateTimestamp(); @@ -224,7 +221,7 @@ export default class IndexController extends Controller { } private updateNotificationCenter() { - this.ianCenterService.updateImmediate(); + document.dispatchEvent(new Event('ian-update-immediate')); } private performAutoScrolling(html:string, journalsContainerAtBottom:boolean) {