Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow override of default behavior of registring W3C notification api with options to resolveContainer #153

Merged
merged 2 commits into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/Electron/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ContainerRegistry.registerContainer("Electron", {
return false;
}
},
create: () => new ElectronContainer()
create: (options) => new ElectronContainer(null, null, null, options)
});

class InternalMessageType {
Expand Down Expand Up @@ -255,7 +255,7 @@ export class ElectronContainer extends WebContainerBase {

public windowOptionsMap: PropertyMap = ElectronContainer.windowOptionsMap;

public constructor(electron?: any, ipc?: NodeJS.EventEmitter | any, win?: any) {
public constructor(electron?: any, ipc?: NodeJS.EventEmitter | any, win?: any, options?: any) {
super(win);
this.hostType = "Electron";

Expand Down Expand Up @@ -286,12 +286,20 @@ export class ElectronContainer extends WebContainerBase {
console.error(e);
}

this.registerNotificationsApi();
let replaceNotificationApi = ElectronContainer.replaceNotificationApi;
if (options && typeof options.replaceNotificationApi !== "undefined") {
replaceNotificationApi = options.replaceNotificationApi;
}

if (replaceNotificationApi) {
this.registerNotificationsApi();
}

this.screen = new ElectronDisplayManager(this.electron);
}

protected registerNotificationsApi() {
if (ElectronContainer.replaceNotificationApi && typeof this.globalWindow !== "undefined" && this.globalWindow) {
if (typeof this.globalWindow !== "undefined" && this.globalWindow) {
// Define owningContainer for closure to inner class
const owningContainer: ElectronContainer = this; // tslint:disable-line

Expand Down
12 changes: 10 additions & 2 deletions src/OpenFin/openfin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,21 @@ export class OpenFinContainer extends WebContainerBase {
}

this.ipc = new OpenFinMessageBus(this.desktop.InterApplicationBus, (<any>this.desktop.Application.getCurrent()).uuid);
this.registerNotificationsApi();

let replaceNotificationApi = OpenFinContainer.replaceNotificationApi;
if (options && typeof options.replaceNotificationApi !== "undefined") {
replaceNotificationApi = options.replaceNotificationApi;
}

if (replaceNotificationApi) {
this.registerNotificationsApi();
}

this.screen = new OpenFinDisplayManager(this.desktop);
}

protected registerNotificationsApi() {
if (OpenFinContainer.replaceNotificationApi && typeof this.globalWindow !== "undefined" && this.globalWindow) {
if (typeof this.globalWindow !== "undefined" && this.globalWindow) {
// Define owningContainer for closure to inner class
const owningContainer: OpenFinContainer = this; // tslint:disable-line

Expand Down