mirror of
https://github.com/bitwarden/browser
synced 2026-03-01 02:51:24 +00:00
feat(notification-processing): [PM-19877] System Notification Implementation - Initial changeset
This commit is contained in:
@@ -22,7 +22,7 @@ export abstract class PlatformUtilsService {
|
||||
abstract isVivaldi(): boolean;
|
||||
abstract isSafari(): boolean;
|
||||
abstract isMacAppStore(): boolean;
|
||||
abstract isViewOpen(): Promise<boolean>;
|
||||
abstract isPopupOpen(): Promise<boolean>;
|
||||
abstract launchUri(uri: string, options?: any): void;
|
||||
abstract getApplicationVersion(): Promise<string>;
|
||||
abstract getApplicationVersionNumber(): Promise<string>;
|
||||
|
||||
3
libs/common/src/platform/actions/actions-service.ts
Normal file
3
libs/common/src/platform/actions/actions-service.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export abstract class ActionsService {
|
||||
abstract openPopup(): Promise<void>;
|
||||
}
|
||||
1
libs/common/src/platform/actions/index.ts
Normal file
1
libs/common/src/platform/actions/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { ActionsService } from "./actions-service";
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ActionsService } from "./actions-service";
|
||||
|
||||
export class UnsupportedActionsService implements ActionsService {
|
||||
openPopup(): Promise<void> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
export { NotificationsService } from "./notifications.service";
|
||||
export { ServerNotificationsService } from "./server-notifications-service";
|
||||
|
||||
@@ -32,7 +32,7 @@ import { EnvironmentService } from "../../abstractions/environment.service";
|
||||
import { LogService } from "../../abstractions/log.service";
|
||||
import { MessagingService } from "../../abstractions/messaging.service";
|
||||
import { supportSwitch } from "../../misc/support-status";
|
||||
import { NotificationsService as NotificationsServiceAbstraction } from "../notifications.service";
|
||||
import { ServerNotificationsService as NotificationsServiceAbstraction } from "../server-notifications-service";
|
||||
|
||||
import { ReceiveMessage, SignalRConnectionService } from "./signalr-connection.service";
|
||||
import { WebPushConnectionService } from "./webpush-connection.service";
|
||||
@@ -188,7 +188,6 @@ export class DefaultNotificationsService implements NotificationsServiceAbstract
|
||||
case NotificationType.SyncCiphers:
|
||||
case NotificationType.SyncSettings:
|
||||
await this.syncService.fullSync(false);
|
||||
|
||||
break;
|
||||
case NotificationType.SyncOrganizations:
|
||||
// An organization update may not have bumped the user's account revision date, so force a sync
|
||||
@@ -214,11 +213,9 @@ export class DefaultNotificationsService implements NotificationsServiceAbstract
|
||||
await this.syncService.syncDeleteSend(notification.payload as SyncSendNotification);
|
||||
break;
|
||||
case NotificationType.AuthRequest:
|
||||
{
|
||||
this.messagingService.send("openLoginApproval", {
|
||||
notificationId: notification.payload.id,
|
||||
});
|
||||
}
|
||||
this.messagingService.send("openLoginApproval", {
|
||||
notificationId: notification.payload.id,
|
||||
});
|
||||
break;
|
||||
case NotificationType.SyncOrganizationStatusChanged:
|
||||
await this.syncService.fullSync(true);
|
||||
|
||||
@@ -4,9 +4,9 @@ import { NotificationResponse } from "@bitwarden/common/models/response/notifica
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { LogService } from "../../abstractions/log.service";
|
||||
import { NotificationsService } from "../notifications.service";
|
||||
import { ServerNotificationsService } from "../server-notifications-service";
|
||||
|
||||
export class NoopNotificationsService implements NotificationsService {
|
||||
export class NoopNotificationsService implements ServerNotificationsService {
|
||||
notifications$: Observable<readonly [NotificationResponse, UserId]> = new Subject();
|
||||
|
||||
constructor(private logService: LogService) {}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DefaultNotificationsService } from "./internal";
|
||||
/**
|
||||
* A service offering abilities to interact with push notifications from the server.
|
||||
*/
|
||||
export abstract class NotificationsService {
|
||||
export abstract class ServerNotificationsService {
|
||||
/**
|
||||
* @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.
|
||||
@@ -9,11 +9,11 @@ export type ButtonActionsKeys = (typeof ButtonActions)[keyof typeof ButtonAction
|
||||
// This is currently tailored for chrome extension's api, if safari works
|
||||
// differently where clicking a notification button produces a different
|
||||
// identifier we need to reconcile that here.
|
||||
export const ButtonLocation = {
|
||||
export const ButtonLocation = Object.freeze({
|
||||
FirstOptionalButton: 0, // this is the first optional button we can set
|
||||
SecondOptionalButton: 1, // this is the second optional button we can set
|
||||
NotificationButton: 2, // this is when you click the notification as a whole
|
||||
};
|
||||
});
|
||||
|
||||
export type ButtonLocationKeys = (typeof ButtonLocation)[keyof typeof ButtonLocation];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user