Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
tomer-openfin committed Oct 7, 2019
2 parents 2bbacb8 + 6ffda2b commit 221a889
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/browser/api/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ Application.getInfo = function(identity, callback) {
Application.getWindow = function(identity) {
let uuid = identity.uuid;

return Window.wrap(uuid, uuid);
return coreState.getWindowByUuidName(uuid, uuid);
};

Application.grantAccess = function() {
Expand Down
7 changes: 6 additions & 1 deletion src/browser/api/browser_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ export function show(ofView: OfView) {

export async function attach(ofView: OfView, toIdentity: Identity) {
const {view, target: previousTarget} = ofView;

if (view && ! view.isDestroyed()) {
const ofWin = getWindowByUuidName(toIdentity.uuid, toIdentity.name);
const oldWin = getWindowByUuidName(previousTarget.uuid, previousTarget.name);

if (!ofWin) {
throw new Error(`Could not locate target window ${toIdentity.uuid}/${toIdentity.name}`);
}
if (!oldWin) {
throw new Error(`Could not locate origin window ${previousTarget.uuid}/${previousTarget.name}`);
}

const oldwinMap = windowCloseListenerMap.get(oldWin);

if (oldWin) {
const oldWinMap = windowCloseListenerMap.get(oldWin);
Expand Down
3 changes: 2 additions & 1 deletion src/browser/api/notifications/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ofEvents from '../../of_events';
const {writeToLog} = require('../../log');
const _ = require('underscore');
import route from '../../../common/route';
import { getWindowByUuidName } from '../../core_state';


const NOTE_APP_UUID = 'service:notifications';
Expand Down Expand Up @@ -622,7 +623,7 @@ function windowIsValid(identity: any): boolean {
let isValid: boolean;

try {
const openfinWindow = Window.wrap(identity.uuid, identity.name);
const openfinWindow = getWindowByUuidName(identity.uuid, identity.name);
const browserWindow = openfinWindow && openfinWindow.browserWindow;

if (!browserWindow) {
Expand Down
31 changes: 13 additions & 18 deletions src/browser/api/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ let optionSetters = {

let uuid = browserWin._options.uuid;
let name = browserWin._options.name;
let openfinWindow = Window.wrap(uuid, name);
let openfinWindow = coreState.getWindowByUuidName(uuid, name);
let hideOnCloseListener = openfinWindow.hideOnCloseListener;
let closeEventString = route.window('close-requested', uuid, name);

Expand Down Expand Up @@ -412,7 +412,7 @@ Window.create = function(id, opts) {

let hideReason = 'hide';
let hideOnCloseListener = () => {
let openfinWindow = Window.wrap(uuid, name);
let openfinWindow = coreState.getWindowByUuidName(uuid, name);
openfinWindow.hideReason = 'hide-on-close';
browserWindow.hide();
};
Expand Down Expand Up @@ -496,7 +496,7 @@ Window.create = function(id, opts) {
// once the window is closed, be sure to close all the children
// it may have and remove it from the
browserWindow.on('close', (event) => {
let ofWindow = Window.wrap(uuid, name);
let ofWindow = coreState.getWindowByUuidName(uuid, name);
let closeEventString = route.window('close-requested', uuid, name);
let listenerCount = ofEvents.listenerCount(closeEventString);

Expand Down Expand Up @@ -570,7 +570,7 @@ Window.create = function(id, opts) {

// if the window has already been removed from core_state,
// don't propagate anymore events
if (!Window.wrap(uuid, name)) {
if (!coreState.getWindowByUuidName(uuid, name)) {
return;
}

Expand Down Expand Up @@ -877,11 +877,6 @@ Window.create = function(id, opts) {
return winObj;
};


Window.wrap = function(uuid, name) {
return coreState.getWindowByUuidName(uuid, name);
};

Window.connected = function() {};

Window.isEmbedded = function() {};
Expand Down Expand Up @@ -1022,7 +1017,7 @@ Window.close = function(identity, force, callback = () => {}) {

let defaultAction = () => {
if (!browserWindow.isDestroyed()) {
let openfinWindow = Window.wrap(identity.uuid, identity.name);
let openfinWindow = coreState.getWindowByUuidName(identity.uuid, identity.name);
openfinWindow.forceClose = true;
browserWindow.close();
}
Expand Down Expand Up @@ -1176,14 +1171,14 @@ Window.getGroup = function(identity) {
return [];
}

let openfinWindow = Window.wrap(identity.uuid, identity.name);
let openfinWindow = coreState.getWindowByUuidName(identity.uuid, identity.name);
return WindowGroups.getGroup(openfinWindow.groupUuid);
};


Window.getWindowInfo = function(identity) {
const browserWindow = getElectronBrowserWindow(identity, 'get info for');
const { preloadScripts } = Window.wrap(identity.uuid, identity.name);
const { preloadScripts } = coreState.getWindowByUuidName(identity.uuid, identity.name);
const windowKey = genWindowKey(identity);
const isUserMovementEnabled = !disabledFrameRef.has(windowKey) || disabledFrameRef.get(windowKey) === 0;
const windowInfo = Object.assign({
Expand Down Expand Up @@ -1298,7 +1293,7 @@ Window.leaveGroup = function(identity) {
return;
}

let openfinWindow = Window.wrap(identity.uuid, identity.name);
let openfinWindow = coreState.getWindowByUuidName(identity.uuid, identity.name);
return WindowGroups.leaveGroup(openfinWindow);
};

Expand Down Expand Up @@ -1798,7 +1793,7 @@ function createWindowTearDown(identity, id, browserWindow, _boundsChangedHandler
// Close all child windows
// Wait for the close event.
return function() {
let ofWindow = Window.wrap(identity.uuid, identity.name);
let ofWindow = coreState.getWindowByUuidName(identity.uuid, identity.name);
let childWindows = coreState.getChildrenByWinId(id) || [];
// remove from core state earlier rather than later
coreState.removeChildById(id);
Expand Down Expand Up @@ -2022,7 +2017,7 @@ function boundsChangeDecorator(payload, args) {
payload[key] = boundsChangePayload[key];
});

let _win = Window.wrap(payload.uuid, payload.name);
let _win = coreState.getWindowByUuidName(payload.uuid, payload.name);
let _browserWin = _win && _win.browserWindow;
setOptOnBrowserWin('x', payload.left, _browserWin);
setOptOnBrowserWin('y', payload.top, _browserWin);
Expand Down Expand Up @@ -2070,7 +2065,7 @@ function willMoveOrResizeDecorator(payload, args) {
}

function opacityChangedDecorator(payload, args) {
let _win = Window.wrap(payload.uuid, payload.name);
let _win = coreState.getWindowByUuidName(payload.uuid, payload.name);
let _browserWin = _win && _win.browserWindow;
setOptOnBrowserWin('opacity', args[1], _browserWin);
return false;
Expand All @@ -2095,7 +2090,7 @@ function visibilityChangedDecorator(payload, args) {
coreState.setSentFirstHideSplashScreen(uuid, true);
}
} else {
let openfinWindow = Window.wrap(payload.uuid, payload.name);
let openfinWindow = coreState.getWindowByUuidName(payload.uuid, payload.name);
const { hideReason } = openfinWindow;
payload.type = 'hidden';
payload.reason = hideReason === 'hide' && closing ? 'closing' : hideReason;
Expand Down Expand Up @@ -2255,7 +2250,7 @@ function handleCustomAlerts(id, opts) {

//If unknown window AND `errDesc` provided, throw error; otherwise return (possibly undefined) browser window ref.
export function getElectronBrowserWindow(identity, errDesc) {
let openfinWindow = Window.wrap(identity.uuid, identity.name);
let openfinWindow = coreState.getWindowByUuidName(identity.uuid, identity.name);
let browserWindow = openfinWindow && openfinWindow.browserWindow;

if (errDesc && !browserWindow) {
Expand Down

0 comments on commit 221a889

Please sign in to comment.