mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
Noop notifications for dev (#6671)
* Noop notifications for dev We rarely have notifications set up for development environments, this removes the error messages related to missing server notification services * Log actions in noop service * Add line breaks * Improve log messages * Ignore local config at all levels
This commit is contained in:
parent
222345f0c9
commit
1d2757e42b
3
.gitignore
vendored
3
.gitignore
vendored
@ -42,3 +42,6 @@ junit.xml
|
||||
documentation.json
|
||||
.eslintcache
|
||||
storybook-static
|
||||
|
||||
# Local app configuration
|
||||
apps/**/config/local.json
|
||||
|
@ -572,12 +572,12 @@ export default class MainBackground {
|
||||
this.stateService
|
||||
);
|
||||
this.notificationsService = new NotificationsService(
|
||||
this.logService,
|
||||
this.syncService,
|
||||
this.appIdService,
|
||||
this.apiService,
|
||||
this.environmentService,
|
||||
logoutCallback,
|
||||
this.logService,
|
||||
this.stateService,
|
||||
this.authService,
|
||||
this.messagingService
|
||||
|
1
apps/cli/.gitignore
vendored
1
apps/cli/.gitignore
vendored
@ -1 +0,0 @@
|
||||
config/local.json
|
@ -13,6 +13,8 @@ console.log("Renderer process config");
|
||||
const envConfig = configurator.load(NODE_ENV);
|
||||
configurator.log(envConfig);
|
||||
|
||||
const ENV = process.env.ENV == null ? "development" : process.env.ENV;
|
||||
|
||||
const common = {
|
||||
module: {
|
||||
rules: [
|
||||
@ -170,6 +172,7 @@ const renderer = {
|
||||
chunkFilename: "[id].[contenthash].css",
|
||||
}),
|
||||
new webpack.EnvironmentPlugin({
|
||||
ENV: ENV,
|
||||
FLAGS: envConfig.flags,
|
||||
DEV_FLAGS: NODE_ENV === "development" ? envConfig.devFlags : {},
|
||||
}),
|
||||
|
1
apps/web/.gitignore
vendored
1
apps/web/.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
!dev-server.shared.pem
|
||||
config/local.json
|
||||
stats.json
|
||||
|
@ -82,7 +82,7 @@ import { StateService as StateServiceAbstraction } from "@bitwarden/common/platf
|
||||
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
||||
import { ValidationService as ValidationServiceAbstraction } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
||||
import { flagEnabled } from "@bitwarden/common/platform/misc/flags";
|
||||
import { devFlagEnabled, flagEnabled } from "@bitwarden/common/platform/misc/flags";
|
||||
import { Account } from "@bitwarden/common/platform/models/domain/account";
|
||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
||||
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
|
||||
@ -94,6 +94,7 @@ import { EncryptServiceImplementation } from "@bitwarden/common/platform/service
|
||||
import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/multithread-encrypt.service.implementation";
|
||||
import { EnvironmentService } from "@bitwarden/common/platform/services/environment.service";
|
||||
import { FileUploadService } from "@bitwarden/common/platform/services/file-upload/file-upload.service";
|
||||
import { NoopNotificationsService } from "@bitwarden/common/platform/services/noop-notifications.service";
|
||||
import { StateService } from "@bitwarden/common/platform/services/state.service";
|
||||
import { ValidationService } from "@bitwarden/common/platform/services/validation.service";
|
||||
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
||||
@ -529,14 +530,16 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
|
||||
},
|
||||
{
|
||||
provide: NotificationsServiceAbstraction,
|
||||
useClass: NotificationsService,
|
||||
useClass: devFlagEnabled("noopNotifications")
|
||||
? NoopNotificationsService
|
||||
: NotificationsService,
|
||||
deps: [
|
||||
LogService,
|
||||
SyncServiceAbstraction,
|
||||
AppIdServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
EnvironmentServiceAbstraction,
|
||||
LOGOUT_CALLBACK,
|
||||
LogService,
|
||||
StateServiceAbstraction,
|
||||
AuthServiceAbstraction,
|
||||
MessagingServiceAbstraction,
|
||||
|
@ -8,7 +8,9 @@ export type SharedFlags = {
|
||||
|
||||
// required to avoid linting errors when there are no flags
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
export type SharedDevFlags = {};
|
||||
export type SharedDevFlags = {
|
||||
noopNotifications: boolean;
|
||||
};
|
||||
|
||||
function getFlags<T>(envFlags: string | T): T {
|
||||
if (typeof envFlags === "string") {
|
||||
|
@ -0,0 +1,28 @@
|
||||
import { NotificationsService as NotificationsServiceAbstraction } from "../../abstractions/notifications.service";
|
||||
import { LogService } from "../abstractions/log.service";
|
||||
|
||||
export class NoopNotificationsService implements NotificationsServiceAbstraction {
|
||||
constructor(private logService: LogService) {}
|
||||
|
||||
init(): Promise<void> {
|
||||
this.logService.info(
|
||||
"Initializing no-op notification service, no push notifications will be received"
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
updateConnection(sync?: boolean): Promise<void> {
|
||||
this.logService.info("Updating notification service connection");
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
reconnectFromActivity(): Promise<void> {
|
||||
this.logService.info("Reconnecting notification service from activity");
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
disconnectFromInactivity(): Promise<void> {
|
||||
this.logService.info("Disconnecting notification service from inactivity");
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
@ -28,12 +28,12 @@ export class NotificationsService implements NotificationsServiceAbstraction {
|
||||
private reconnectTimer: any = null;
|
||||
|
||||
constructor(
|
||||
private logService: LogService,
|
||||
private syncService: SyncService,
|
||||
private appIdService: AppIdService,
|
||||
private apiService: ApiService,
|
||||
private environmentService: EnvironmentService,
|
||||
private logoutCallback: (expired: boolean) => Promise<void>,
|
||||
private logService: LogService,
|
||||
private stateService: StateService,
|
||||
private authService: AuthService,
|
||||
private messagingService: MessagingService
|
||||
|
Loading…
Reference in New Issue
Block a user