1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-19806] Add Special Foreground Notifications Service (#14094)

* Add Special Foreground Notifications Service

* Add link to method
This commit is contained in:
Justin Baur
2025-04-03 08:47:32 -04:00
committed by GitHub
parent bd490e3af9
commit e697f73fd5
4 changed files with 48 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import {
map,
mergeMap,
Observable,
share,
switchMap,
} from "rxjs";
@@ -66,6 +67,7 @@ export class DefaultNotificationsService implements NotificationsServiceAbstract
map((notification) => [notification, activeAccountId] as const),
);
}),
share(), // Multiple subscribers should only create a single connection to the server
);
}

View File

@@ -3,10 +3,18 @@ import { Observable, Subscription } from "rxjs";
import { NotificationResponse } from "@bitwarden/common/models/response/notification.response";
import { UserId } from "@bitwarden/common/types/guid";
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Needed to link to API
import type { DefaultNotificationsService } from "./internal";
/**
* A service offering abilities to interact with push notifications from the server.
*/
export abstract class NotificationsService {
/**
* @deprecated This method should not be consumed, an observable to listen to server
* notifications will be available one day but it is not ready to be consumed generally.
* Please add code reacting to notifications in {@link DefaultNotificationsService.processNotification}
*/
abstract notifications$: Observable<readonly [NotificationResponse, UserId]>;
/**
* Starts automatic listening and processing of notifications, should only be called once per application,