From 48ebe85b51e510d00a098d2077688cb52c330751 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Mon, 4 Dec 2023 16:59:08 +0100 Subject: [PATCH] MOBILE-3947 core: Fix null injection token --- src/core/constants.ts | 7 +++++++ src/core/services/storage.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/constants.ts b/src/core/constants.ts index 5dab49dcc..35a26c3b0 100644 --- a/src/core/constants.ts +++ b/src/core/constants.ts @@ -14,8 +14,15 @@ import envJson from '@/assets/env.json'; import { EnvironmentConfig } from '@/types/config'; +import { InjectionToken } from '@angular/core'; import { CoreBrowser } from '@singletons/browser'; +/** + * Injection token used for dependencies marked as optional that will never + * be resolved by Angular injectors. + */ +export const NULL_INJECTION_TOKEN = new InjectionToken('null'); + /** * Context levels enumeration. */ diff --git a/src/core/services/storage.ts b/src/core/services/storage.ts index 25066f221..4191f8060 100644 --- a/src/core/services/storage.ts +++ b/src/core/services/storage.ts @@ -24,6 +24,7 @@ import { SQLiteDB } from '@classes/sqlitedb'; import { APP_SCHEMA, CoreStorageRecord, TABLE_NAME } from './database/storage'; import { CoreSites } from './sites'; import { CoreSite } from '@classes/sites/site'; +import { NULL_INJECTION_TOKEN } from '@/core/constants'; /** * Service to store data using key-value pairs. @@ -38,7 +39,7 @@ export class CoreStorageService { table: AsyncInstance; - constructor(@Optional() @Inject(null) lazyTableConstructor?: () => Promise) { + constructor(@Optional() @Inject(NULL_INJECTION_TOKEN) lazyTableConstructor?: () => Promise) { this.table = asyncInstance(lazyTableConstructor); }