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

Fix extension detection #6452

Merged
merged 6 commits into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
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%;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes display of accounts on firefox (especially in Parity Bar when selecting default account, the accounts were overlapping).


&:hover {
filter: none;
Expand Down
28 changes: 18 additions & 10 deletions js/src/views/Application/Extension/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,27 @@ export default class Store {
}

@action testInstall = () => {
this.shouldInstall = this.readStatus();
this.readStatus()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MobX sometimes does things a bit funny when dealing with promises, i.e. not firing updates when inside a promise chain. Generally it would be preferable to...

@action setInstallStatus = (shouldInstall) => {
  this.shouldInstall = shouldInstall;
}

testInstall = () => {
  this.readStatus().then(this.setInstallStatus);
}

.then(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;
}

return (ua || {}).name.toLowerCase() === 'chrome';
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