From b5b16e4ce09b5fa27ce4775b30a44bacea7ee329 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 12 Feb 2018 13:25:00 -0330 Subject: [PATCH] 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',