Skip to content

Commit

Permalink
Bug/58787 notification banner is showing up on all pages (#17114)
Browse files Browse the repository at this point in the history
fix global instantiation of ian center state
  • Loading branch information
jjabari-op authored Nov 5, 2024
1 parent 9bb90d2 commit c672fd9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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)),
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/app/features/plugins/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c672fd9

Please sign in to comment.