Skip to content

Commit

Permalink
Merge pull request #1146 from OneSignal/clean/player_references
Browse files Browse the repository at this point in the history
Cleanup player references
  • Loading branch information
jkasten2 authored Dec 13, 2023
2 parents b7121cd + fc8f047 commit dbd6402
Show file tree
Hide file tree
Showing 73 changed files with 99 additions and 3,719 deletions.
3 changes: 0 additions & 3 deletions __test__/support/environment/TestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ export default class TestContext {
enable: true,
mixpanel_reporting_token: '7c2582e45a6ecf1501aa3ca7887f3673',
},
email: {
require_auth: true,
},
web_on_focus_enabled: true,
session_threshold: 30,
},
Expand Down
4 changes: 0 additions & 4 deletions __test__/support/environment/TestEnvironment.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import SdkEnvironment from '../../../src/shared/managers/SdkEnvironment';
import {
AppUserConfig,
ConfigIntegrationKind,
ServerAppConfig,
} from '../../../src/shared/models/AppConfig';
import { TestEnvironmentKind } from '../../../src/shared/models/TestEnvironmentKind';
import BrowserUserAgent from '../models/BrowserUserAgent';
import {
resetDatabase,
Expand Down Expand Up @@ -72,8 +70,6 @@ export class TestEnvironment {
);
}

SdkEnvironment.getTestEnv = () => TestEnvironmentKind.UnitTesting;

await stubDomEnvironment(config);
config.environment = 'dom';
stubNotification(config);
Expand Down
18 changes: 9 additions & 9 deletions __test__/support/helpers/sdkVersion.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export function expectHeaderToBeSent() {
expect(window.fetch).toHaveBeenCalledWith(
expect.any(String),
expect.objectContaining({
headers: expect.objectContaining({
// made undercase automatically
'sdk-version': expect.stringMatching(/onesignal\/web\/[0-9]+[0-9]+/),
}),
}),
);
jest.mocked(window.fetch).mock.calls.forEach((params) => {
expect(typeof params[0]).toBe('string');

const requestInit = params[1] as RequestInit;
const headers = requestInit.headers as Headers;
expect(headers.get('sdk-version')).toMatch(
new RegExp(/^onesignal\/web\/[0-9]{6}$/),
);
});
}
1 change: 0 additions & 1 deletion __test__/support/mocks/models/MockServiceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import NotImplementedError from '../../../../src/shared/errors/NotImplementedErr

export class MockServiceWorker implements ServiceWorker {
scriptURL: string;
state: ServiceWorkerState;

constructor() {}

Expand Down
25 changes: 0 additions & 25 deletions __test__/unit/helpers/mainHelper.test.ts

This file was deleted.

10 changes: 10 additions & 0 deletions src/core/CoreModuleDirector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ export class CoreModuleDirector {
};
}

public async hasEmail(): Promise<boolean> {
const emails = await this.getEmailSubscriptionModels();
return Object.keys(emails).length > 0;
}

public getSmsSubscriptionModels(): {
[key: string]: OSModel<SupportedSubscription>;
} {
Expand All @@ -187,6 +192,11 @@ export class CoreModuleDirector {
};
}

public async hasSms(): Promise<boolean> {
const smsModels = await this.getSmsSubscriptionModels();
return Object.keys(smsModels).length > 0;
}

/**
* Returns all push subscription models, including push subscriptions from other browsers.
*/
Expand Down
9 changes: 1 addition & 8 deletions src/core/models/SubscriptionModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@ import { SubscriptionStateKind } from '../../shared/models/SubscriptionStateKind
export type SupportedSubscription = SubscriptionModel | FutureSubscriptionModel;

export enum SubscriptionType {
iOS = 'iOS',
Android = 'Android',
FireOS = 'FireOS',
ChromeExtension = 'ChromeExtension',
ChromePush = 'ChromePush',
WindowPush = 'WindowPush',
SafariPush = 'SafariPush',
SafariLegacyPush = 'SafariLegacyPush',
FirefoxPush = 'FirefoxPush',
HuaweiPush = 'HuaweiPush',
macOSPush = 'macOSPush',
AlexaPush = 'AlexaPush',
Email = 'Email',
SMS = 'SMS',
// There are other OneSignal types, but only including ones used here.
}

export interface FutureSubscriptionModel {
Expand Down
2 changes: 0 additions & 2 deletions src/onesignal/OneSignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Emitter from '../shared/libraries/Emitter';
import Log from '../shared/libraries/Log';
import SdkEnvironment from '../shared/managers/SdkEnvironment';
import { AppUserConfig, AppConfig } from '../shared/models/AppConfig';
import { DeviceRecord } from '../shared/models/DeviceRecord';
import { AppUserConfigNotifyButton } from '../shared/models/Prompts';
import Database from '../shared/services/Database';
import { logMethodCall } from '../shared/utils/utils';
Expand Down Expand Up @@ -293,7 +292,6 @@ export default class OneSignal {
static _initCalled = false;
static __initAlreadyCalled = false;
static context: Context;
static DeviceRecord = DeviceRecord;

/* NEW USER MODEL CHANGES */
static coreDirector: CoreModuleDirector;
Expand Down
8 changes: 0 additions & 8 deletions src/onesignal/OneSignalEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ export const ONESIGNAL_EVENTS = {
* Occurs when the native permission prompt is displayed.
*/
PERMISSION_PROMPT_DISPLAYED: 'permissionPromptDisplay',
/**
* Occurs when the email subscription changes
*/
EMAIL_SUBSCRIPTION_CHANGED: 'emailSubscriptionChanged',
/**
* Occurs when the SMS subscription changes
*/
SMS_SUBSCRIPTION_CHANGED: 'smsSubscriptionChanged',
/**
* For internal testing only. Used for all sorts of things.
*/
Expand Down
68 changes: 0 additions & 68 deletions src/page/helpers/AuthHashOptionsValidatorHelper.ts

This file was deleted.

137 changes: 0 additions & 137 deletions src/page/managers/MetricsManager.ts

This file was deleted.

Loading

0 comments on commit dbd6402

Please sign in to comment.