Open popup without attempting inline (#4440) (#4441)

* Open popup without attempting inline

* Cater for all .web3.site addresses
This commit is contained in:
Tomasz Drwięga 2017-02-06 09:53:11 +01:00 committed by Jaco Greeff
parent 43bb862adb
commit ab2d02bbb6
2 changed files with 19 additions and 5 deletions

View File

@ -21,9 +21,12 @@ const MAX_GAS_ESTIMATION = '50000000';
const NULL_ADDRESS = '0000000000000000000000000000000000000000'; const NULL_ADDRESS = '0000000000000000000000000000000000000000';
const DOMAIN = '.web3.site';
export { export {
DEFAULT_GAS, DEFAULT_GAS,
DEFAULT_GASPRICE, DEFAULT_GASPRICE,
MAX_GAS_ESTIMATION, MAX_GAS_ESTIMATION,
NULL_ADDRESS NULL_ADDRESS,
DOMAIN
}; };

View File

@ -21,6 +21,8 @@ import { action, computed, observable } from 'mobx';
import store from 'store'; import store from 'store';
import browser from 'useragent.js/lib/browser'; import browser from 'useragent.js/lib/browser';
import { DOMAIN } from '~/util/constants';
const A_DAY = 24 * 60 * 60 * 1000; const A_DAY = 24 * 60 * 60 * 1000;
const NEXT_DISPLAY = '_parity::extensionWarning::nextDisplay'; const NEXT_DISPLAY = '_parity::extensionWarning::nextDisplay';
@ -68,6 +70,19 @@ export default class Store {
installExtension = () => { installExtension = () => {
this.setInstalling(true); 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) => { return new Promise((resolve, reject) => {
const link = document.createElement('link'); const link = document.createElement('link');
@ -80,10 +95,6 @@ export default class Store {
} else { } else {
reject(new Error('Direct installation failed.')); reject(new Error('Direct installation failed.'));
} }
})
.catch((error) => {
console.warn('Unable to perform direct install', error);
window.open(EXTENSION_PAGE, '_blank');
}); });
} }
} }