Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Also request notifications from inactive tabs at much larger intervals

Oliver Günther1d2583867f6d
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 178aac37225..8aac0518fd8 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
@@ -2,15 +2,16 @@ import {
ChangeDetectionStrategy,
Component,
} from '@angular/core';
-import { OpModalService } from 'core-app/shared/components/modal/modal.service';
import {
combineLatest,
+ merge,
timer,
} from 'rxjs';
import {
filter,
map,
switchMap,
+ throttleTime,
} from 'rxjs/operators';
import { ActiveWindowService } from 'core-app/core/active-window/active-window.service';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
@@ -18,7 +19,8 @@ import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';
export const opInAppNotificationBellSelector = 'op-in-app-notification-bell';
-const POLLING_INTERVAL = 10000;
+const ACTIVE_POLLING_INTERVAL = 10000;
+const INACTIVE_POLLING_INTERVAL = 120000;
@Component({
selector: opInAppNotificationBellSelector,
@@ -27,10 +29,14 @@ const POLLING_INTERVAL = 10000;
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InAppNotificationBellComponent {
- polling$ = timer(10, POLLING_INTERVAL).pipe(
- filter(() => this.activeWindow.isActive),
- switchMap(() => this.storeService.fetchUnread()),
- );
+ polling$ = merge(
+ timer(10, ACTIVE_POLLING_INTERVAL).pipe(filter(() => this.activeWindow.isActive)),
+ timer(10, INACTIVE_POLLING_INTERVAL).pipe(filter(() => !this.activeWindow.isActive)),
+ )
+ .pipe(
+ throttleTime(ACTIVE_POLLING_INTERVAL),
+ switchMap(() => this.storeService.fetchUnread()),
+ );
unreadCount$ = combineLatest([
this.storeService.unread$,
@@ -41,7 +47,6 @@ export class InAppNotificationBellComponent {
readonly storeService:IanBellService,
readonly apiV3Service:ApiV3Service,
readonly activeWindow:ActiveWindowService,
- readonly modalService:OpModalService,
readonly pathHelper:PathHelperService,
) { }