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

[beta] Opening extension page without inline installation #4441

Merged
merged 1 commit into from
Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion js/src/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
19 changes: 15 additions & 4 deletions js/src/views/Application/Extension/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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');

Expand All @@ -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');
});
}
}