From 6fed8e7f8c07078d9d6f91eca2dcf47cf3153753 Mon Sep 17 00:00:00 2001 From: vbaranov Date: Fri, 26 Oct 2018 20:30:51 +0300 Subject: [PATCH 1/2] Unreleased interval and events --- app/scripts/controllers/blacklist.js | 4 +++- old-ui/app/components/menu-droppo.js | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js index 89c7cc888..88de61a7f 100644 --- a/app/scripts/controllers/blacklist.js +++ b/app/scripts/controllers/blacklist.js @@ -96,7 +96,9 @@ class BlacklistController { * */ scheduleUpdates () { - if (this._phishingUpdateIntervalRef) return + if (this._phishingUpdateIntervalRef) { + clearInterval(this._phishingUpdateIntervalRef) + } this.updatePhishingList().catch(log.warn) this._phishingUpdateIntervalRef = setInterval(() => { this.updatePhishingList().catch(log.warn) diff --git a/old-ui/app/components/menu-droppo.js b/old-ui/app/components/menu-droppo.js index ca07badf3..4efc79281 100644 --- a/old-ui/app/components/menu-droppo.js +++ b/old-ui/app/components/menu-droppo.js @@ -80,24 +80,24 @@ MenuDroppoComponent.prototype.componentDidMount = function () { this.container = container } + this.transitionStarted = this.transitionstartOccured.bind(this) + /* * transitionstart event is not supported in Chrome yet. But it works for Firefox 53+. * We need to handle this event only for FF because for Chrome we've hidden scrolls. */ - this.refs.menuDroppoContainer.addEventListener('transitionstart', () => { - this.refs.menuDroppoContainer.style.overflow = 'hidden' - }) + this.refs.menuDroppoContainer.addEventListener('transitionstart', this.transitionStarted) - this.refs.menuDroppoContainer.addEventListener('transitionend', () => { - if (!this.props.constOverflow) { - this.refs.menuDroppoContainer.style.overflow = 'auto' - } - }) + this.transitionEnded = this.transitionendOccured.bind(this) + + this.refs.menuDroppoContainer.addEventListener('transitionend', this.transitionEnded) } MenuDroppoComponent.prototype.componentWillUnmount = function () { if (this && document.body) { document.body.removeEventListener('click', this.globalClickHandler) + document.body.removeEventListener('transitionstart', this.transitionStarted) + document.body.removeEventListener('transitionend', this.transitionEnded) } } @@ -113,6 +113,16 @@ MenuDroppoComponent.prototype.globalClickOccurred = function (event) { } } +MenuDroppoComponent.prototype.transitionstartOccured = function (event) { + this.refs.menuDroppoContainer.style.overflow = 'hidden' +} + +MenuDroppoComponent.prototype.transitionendOccured = function (event) { + if (!this.props.constOverflow) { + this.refs.menuDroppoContainer.style.overflow = 'auto' + } +} + function isDescendant (parent, child) { var node = child.parentNode while (node !== null) { From 3b878f3dba3585dfd01c82f9ebf9948a91f4e3f8 Mon Sep 17 00:00:00 2001 From: vbaranov Date: Mon, 29 Oct 2018 17:12:08 +0300 Subject: [PATCH 2/2] remove listener on clicked notification --- app/scripts/platforms/extension.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 3bbdfa4bc..03543829a 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -109,15 +109,16 @@ class ExtensionPlatform { }) } - _subscribeToNotificationClicked () { - if (!extension.notifications.onClicked.hasListener(this._viewOnEtherScan)) { - extension.notifications.onClicked.addListener(this._viewOnEtherScan) + _subscribeToNotificationClicked = () => { + if (!extension.notifications.onClicked.hasListener(this._viewOnExplorer)) { + extension.notifications.onClicked.addListener((url) => this._viewOnExplorer(url)) } } - _viewOnEtherScan (txId) { - if (txId.startsWith('http://') || txId.startsWith('https://')) { - global.metamaskController.platform.openWindow({ url: txId }) + _viewOnExplorer (url) { + if (url.startsWith('http://') || url.startsWith('https://')) { + extension.notifications.onClicked.removeListener(this._viewOnExplorer) + global.metamaskController.platform.openWindow({ url }) } }