From b5b16e4ce09b5fa27ce4775b30a44bacea7ee329 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 12 Feb 2018 13:25:00 -0330 Subject: [PATCH 1/2] Only open a new window on restore from seed if in extension view. --- app/scripts/platforms/extension.js | 16 ++++++++++++++++ ui/app/actions.js | 2 -- ui/app/unlock.js | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index f5cc255d1..60bcce324 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -22,6 +22,22 @@ class ExtensionPlatform { this.openWindow({ url: extensionURL }) } + isInBrowser () { + return new Promise((resolve, reject) => { + try { + extension.tabs.getCurrent(currentTab => { + if (currentTab) { + resolve(true) + } else { + resolve(false) + } + }) + } catch (e) { + reject(e) + } + }) + } + getPlatformInfo (cb) { try { extension.runtime.getPlatformInfo((platform) => { diff --git a/ui/app/actions.js b/ui/app/actions.js index c6776eeee..4bc1f379e 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -842,7 +842,6 @@ function showRestoreVault () { function markPasswordForgotten () { return (dispatch) => { - dispatch(actions.showLoadingIndication()) return background.markPasswordForgotten(() => { dispatch(actions.hideLoadingIndication()) dispatch(actions.forgotPassword()) @@ -853,7 +852,6 @@ function markPasswordForgotten () { function unMarkPasswordForgotten () { return (dispatch) => { - dispatch(actions.showLoadingIndication()) return background.unMarkPasswordForgotten(() => { dispatch(actions.hideLoadingIndication()) dispatch(actions.forgotPassword()) diff --git a/ui/app/unlock.js b/ui/app/unlock.js index 4b39bd3e2..db88fa9d0 100644 --- a/ui/app/unlock.js +++ b/ui/app/unlock.js @@ -77,7 +77,12 @@ UnlockScreen.prototype.render = function () { h('p.pointer', { onClick: () => { this.props.dispatch(actions.markPasswordForgotten()) - global.platform.openExtensionInBrowser() + global.platform.isInBrowser() + .then((isInBrowser) => { + if (!isInBrowser) { + global.platform.openExtensionInBrowser() + } + }) }, style: { fontSize: '0.8em', From 5e9dc74a59d2507f36e1cb5796f97982f5f4993d Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 13 Feb 2018 14:29:43 -0330 Subject: [PATCH 2/2] Remove isInBrowser method and use environment-type.js --- app/scripts/platforms/extension.js | 16 ---------------- ui/app/unlock.js | 10 ++++------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 60bcce324..f5cc255d1 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -22,22 +22,6 @@ class ExtensionPlatform { this.openWindow({ url: extensionURL }) } - isInBrowser () { - return new Promise((resolve, reject) => { - try { - extension.tabs.getCurrent(currentTab => { - if (currentTab) { - resolve(true) - } else { - resolve(false) - } - }) - } catch (e) { - reject(e) - } - }) - } - getPlatformInfo (cb) { try { extension.runtime.getPlatformInfo((platform) => { diff --git a/ui/app/unlock.js b/ui/app/unlock.js index db88fa9d0..13c3f1274 100644 --- a/ui/app/unlock.js +++ b/ui/app/unlock.js @@ -6,6 +6,7 @@ const actions = require('./actions') const getCaretCoordinates = require('textarea-caret') const EventEmitter = require('events').EventEmitter const { OLD_UI_NETWORK_TYPE } = require('../../app/scripts/config').enums +const environmentType = require('../../app/scripts/lib/environment-type') const Mascot = require('./components/mascot') @@ -77,12 +78,9 @@ UnlockScreen.prototype.render = function () { h('p.pointer', { onClick: () => { this.props.dispatch(actions.markPasswordForgotten()) - global.platform.isInBrowser() - .then((isInBrowser) => { - if (!isInBrowser) { - global.platform.openExtensionInBrowser() - } - }) + if (environmentType() === 'popup') { + global.platform.openExtensionInBrowser() + } }, style: { fontSize: '0.8em',