diff --git a/build/config/tsconfig.base.json b/build/config/tsconfig.base.json index 0cec68380..48c345695 100644 --- a/build/config/tsconfig.base.json +++ b/build/config/tsconfig.base.json @@ -8,8 +8,8 @@ "noImplicitAny": false, "noImplicitReturns": true, "noImplicitThis": true, - "noUnusedLocals": false, - "noUnusedParameters": false, + "noUnusedLocals": true, + "noUnusedParameters": true, "allowSyntheticDefaultImports": true, "allowUnreachableCode": false, "allowUnusedLabels": false, @@ -27,6 +27,7 @@ "sourceRoot": "../..", "rootDir": "../..", "esModuleInterop": true, + "strictFunctionTypes": true, "baseUrl": "../..", "types": [ "node" diff --git a/src/page/bell/Bell.ts b/src/page/bell/Bell.ts index a03dd3c8e..5c9ed3cb2 100755 --- a/src/page/bell/Bell.ts +++ b/src/page/bell/Bell.ts @@ -494,9 +494,7 @@ export default class Bell { const isPushEnabled = await OneSignal.context.subscriptionManager.isPushNotificationsEnabled(); - const doNotPrompt = DismissHelper.wasPromptOfTypeDismissed( - DismissPrompt.Push, - ); + DismissHelper.wasPromptOfTypeDismissed(DismissPrompt.Push); // Resize to small instead of specified size if enabled, otherwise there's a jerking motion // where the bell, at a different size than small, jerks sideways to go from large -> small or medium -> small diff --git a/src/page/bell/Dialog.ts b/src/page/bell/Dialog.ts index 02178197f..4b50099aa 100755 --- a/src/page/bell/Dialog.ts +++ b/src/page/bell/Dialog.ts @@ -1,5 +1,3 @@ -import bowser from 'bowser'; - import OneSignalEvent from '../../shared/services/OneSignalEvent'; import SdkEnvironment from '../../shared/managers/SdkEnvironment'; import { diff --git a/src/page/managers/PromptsManager.ts b/src/page/managers/PromptsManager.ts index 3870fbb92..3fdc8f290 100644 --- a/src/page/managers/PromptsManager.ts +++ b/src/page/managers/PromptsManager.ts @@ -6,7 +6,6 @@ import { } from '../../shared/config/constants'; import { DismissHelper } from '../../shared/helpers/DismissHelper'; import InitHelper from '../../shared/helpers/InitHelper'; -import MainHelper from '../../shared/helpers/MainHelper'; import PromptsHelper from '../../shared/helpers/PromptsHelper'; import Log from '../../shared/libraries/Log'; import { diff --git a/src/shared/helpers/EventHelper.ts b/src/shared/helpers/EventHelper.ts index f5dded02a..ce45796a3 100755 --- a/src/shared/helpers/EventHelper.ts +++ b/src/shared/helpers/EventHelper.ts @@ -1,4 +1,3 @@ -import OneSignalApiShared from '../api/OneSignalApiShared'; import Log from '../libraries/Log'; import { CustomLinkManager } from '../managers/CustomLinkManager'; import { ContextSWInterface } from '../models/ContextSW'; diff --git a/src/shared/managers/SubscriptionManager.ts b/src/shared/managers/SubscriptionManager.ts index 7b37ce256..ab98c4fe7 100644 --- a/src/shared/managers/SubscriptionManager.ts +++ b/src/shared/managers/SubscriptionManager.ts @@ -242,7 +242,9 @@ export class SubscriptionManager { * @param rawPushSubscription The raw push subscription obtained from calling subscribe(). This * can be null, in which case OneSignal's device record is set to unsubscribed. * - * @param subscriptionState Describes whether the device record is subscribed, unsubscribed, or in + * @param subscriptionState TODO: This is no longer used here and needs some refactoring to + * put this back into place. + * Describes whether the device record is subscribed, unsubscribed, or in * another state. By default, this is set from the availability of rawPushSubscription (exists: * Subscribed, null: Unsubscribed). Other use cases may result in creation of a device record that * warrants a special subscription state. For example, a device ID can be retrieved by providing @@ -251,7 +253,7 @@ export class SubscriptionManager { */ public async registerSubscription( pushSubscription: RawPushSubscription, - subscriptionState?: SubscriptionStateKind, + _subscriptionState?: SubscriptionStateKind, ): Promise { /* This may be called after the RawPushSubscription has been serialized across a postMessage @@ -477,6 +479,10 @@ export class SubscriptionManager { await this.context.serviceWorkerManager.installWorker(); } catch (err) { if (err instanceof ServiceWorkerRegistrationError) { + // TODO: This doesn't register the subscription any more, most likely broke + // in some refactoring in the v16 major release. It would be useful if a + // subscription was created so the customer knows this failed by seeing + // subscriptions in this state on the OneSignal dashboard. if (err.status === 403) { await this.context.subscriptionManager.registerFailedSubscription( SubscriptionStateKind.ServiceWorkerStatus403, diff --git a/src/shared/utils/Encoding.ts b/src/shared/utils/Encoding.ts index 7f30d7239..9c3d17b69 100644 --- a/src/shared/utils/Encoding.ts +++ b/src/shared/utils/Encoding.ts @@ -70,35 +70,6 @@ export function arrayBufferToBase64(arrayBuffer: ArrayBufferLike): string { return base64; } -/** - * From: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding - */ -export function base64Encode(str) { - // first we use encodeURIComponent to get percent-encoded UTF-8, - // then we convert the percent encodings into raw bytes which - // can be fed into btoa. - return btoa( - encodeURIComponent(str).replace( - /%([0-9A-F]{2})/g, - function toSolidBytes(match, p1) { - return String.fromCharCode(('0x' as any) + p1); - }, - ), - ); -} - -export function base64Decode(str) { - // Going backwards: from bytestream, to percent-encoding, to original string. - return decodeURIComponent( - atob(str) - .split('') - .map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); - }) - .join(''), - ); -} - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986 export function encodeRFC3986URIComponent(str: string): string { return encodeURIComponent(str).replace( diff --git a/src/shared/utils/utils.ts b/src/shared/utils/utils.ts index 74a252a0e..85dba386c 100755 --- a/src/shared/utils/utils.ts +++ b/src/shared/utils/utils.ts @@ -1,6 +1,5 @@ import SdkEnvironment from '../managers/SdkEnvironment'; import { WindowEnvironmentKind } from '../models/WindowEnvironmentKind'; -import Database from '../services/Database'; import { OneSignalUtils } from './OneSignalUtils'; import { PermissionUtils } from './PermissionUtils'; import { Utils } from '../context/Utils'; diff --git a/tsconfig.json b/tsconfig.json index 7e7f5b119..e8654add4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,10 +10,7 @@ "strictNullChecks": true, "checkJs": true, "noImplicitAny": true, - "noUnusedLocals": true, - "noUnusedParameters": true, "strictPropertyInitialization": true, - "strictFunctionTypes": true, "baseUrl": ".", "types": ["jest", "node"] },