From ab2d02bbb6dd710f5c250543c9faf2c0055baaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 6 Feb 2017 09:53:11 +0100 Subject: [PATCH] Open popup without attempting inline (#4440) (#4441) * Open popup without attempting inline * Cater for all .web3.site addresses --- js/src/util/constants.js | 5 ++++- js/src/views/Application/Extension/store.js | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/js/src/util/constants.js b/js/src/util/constants.js index 109c060dd..c1349a7dc 100644 --- a/js/src/util/constants.js +++ b/js/src/util/constants.js @@ -21,9 +21,12 @@ const MAX_GAS_ESTIMATION = '50000000'; const NULL_ADDRESS = '0000000000000000000000000000000000000000'; +const DOMAIN = '.web3.site'; + export { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION, - NULL_ADDRESS + NULL_ADDRESS, + DOMAIN }; diff --git a/js/src/views/Application/Extension/store.js b/js/src/views/Application/Extension/store.js index 40a3f09e7..965598f03 100644 --- a/js/src/views/Application/Extension/store.js +++ b/js/src/views/Application/Extension/store.js @@ -21,6 +21,8 @@ import { action, computed, observable } from 'mobx'; import store from 'store'; import browser from 'useragent.js/lib/browser'; +import { DOMAIN } from '~/util/constants'; + const A_DAY = 24 * 60 * 60 * 1000; const NEXT_DISPLAY = '_parity::extensionWarning::nextDisplay'; @@ -68,6 +70,19 @@ export default class Store { installExtension = () => { this.setInstalling(true); + if (window.location.hostname.toString().endsWith(DOMAIN)) { + return this.inlineInstall() + .catch((error) => { + console.warn('Unable to perform direct install', error); + window.open(EXTENSION_PAGE, '_blank'); + }); + } + + window.open(EXTENSION_PAGE, '_blank'); + return Promise.resolve(true); + } + + inlineInstall = () => { return new Promise((resolve, reject) => { const link = document.createElement('link'); @@ -80,10 +95,6 @@ export default class Store { } else { reject(new Error('Direct installation failed.')); } - }) - .catch((error) => { - console.warn('Unable to perform direct install', error); - window.open(EXTENSION_PAGE, '_blank'); }); } }