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

Commit

Permalink
Fix extension detection (#6452)
Browse files Browse the repository at this point in the history
* Fix extension detection.

* Fix mobx quirks.

* Update submodule.
  • Loading branch information
tomusdrw authored and gavofyork committed Sep 15, 2017
1 parent 54bd7d2 commit b602fb4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions js/src/ui/SelectionList/selectionList.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
height: 100%;
position: relative;
width: 100%;
max-width: 100%;

&:hover {
filter: none;
Expand Down
32 changes: 20 additions & 12 deletions js/src/views/Application/Extension/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default class Store {

constructor () {
this.nextDisplay = store.get(NEXT_DISPLAY) || 0;
this.testInstall();
}

@computed get showWarning () {
Expand All @@ -59,20 +58,29 @@ export default class Store {
store.set(NEXT_DISPLAY, this.nextDisplay);
}

@action testInstall = () => {
this.shouldInstall = this.readStatus();
@action setShouldInstall = (status) => {
this.shouldInstall = status;
}

readStatus = () => {
const hasExtension = Symbol.for('parity.extension') in window;
const ua = browser.analyze(navigator.userAgent || '');

if (hasExtension) {
this.setExtensionActive();
return false;
}
testInstall = () => {
this.readStatus().then(this.setShouldInstall);
}

return (ua || {}).name.toLowerCase() === 'chrome';
readStatus = () => {
return new Promise((resolve, reject) => {
// Defer checking for the extension since it may not have loaded yet.
setTimeout(() => {
const hasExtension = Symbol.for('parity.extension') in window;
const ua = browser.analyze(navigator.userAgent || '');

if (hasExtension) {
this.setExtensionActive();
return resolve(false);
}

return resolve((ua || {}).name.toLowerCase() === 'chrome');
}, 5000);
});
}

installExtension = () => {
Expand Down

0 comments on commit b602fb4

Please sign in to comment.