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

Prevent toasts on loading errors from notifications

Oliver Günther5406045d94e0
diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts
index 14983eac198..87c4a00d0a3 100644
--- a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts
+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts
@@ -60,10 +60,6 @@ export class InAppNotificationsResourceService {
.get<IHALCollection<InAppNotification>>(this.notificationsPath + collectionURL)
.pipe(
tap((collection) => insertCollectionIntoState(this.store, collection, collectionURL)),
- catchError((error) => {
- this.toastService.addError(error);
- throw error;
- }),
);
}
diff --git a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html
index 6c7fc8ca1ea..5886cc576d2 100644
--- a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html
+++ b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html
@@ -6,10 +6,10 @@
<op-icon icon-classes="icon-bell"></op-icon>
<ng-container *ngIf="(unreadCount$ | async) as unreadCount">
<span
- *ngIf="unreadCount > 0"
+ *ngIf="unreadCount !== 0"
class="op-ian-bell--indicator"
data-qa-selector="op-ian-notifications-count"
- [textContent]="unreadCount > 99 ? '' : unreadCount"
+ [textContent]="(unreadCount === -1 || unreadCount > 99) ? '' : unreadCount"
></span>
</ng-container>
-</a>
\ No newline at end of file
+</a>
diff --git a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
index 49559103432..65a344a03fe 100644
--- a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
+++ b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
@@ -6,8 +6,12 @@ import {
map,
tap,
skip,
+ catchError,
} from 'rxjs/operators';
-import { Observable } from 'rxjs';
+import {
+ EMPTY,
+ Observable,
+} from 'rxjs';
import { IanBellQuery } from 'core-app/features/in-app-notifications/bell/state/ian-bell.query';
import {
EffectCallback,
@@ -46,9 +50,16 @@ export class IanBellService {
.fetchNotifications({ filters: IAN_FACET_FILTERS.unread, pageSize: 0 })
.pipe(
map((result) => result.total),
- tap((count) => {
- this.store.update({ totalUnread: count });
- }),
+ tap(
+ (count) => {
+ this.store.update({ totalUnread: count });
+ },
+ (error) => {
+ console.error('Failed to load notifications: %O', error);
+ this.store.update({ totalUnread: -1 });
+ },
+ ),
+ catchError(() => EMPTY),
);
}