aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-11-27 00:21:52 +0800
committerGitHub <noreply@github.com>2018-11-27 00:21:52 +0800
commiteec7fcebd528a70b5c8a3571c5b802ced889e626 (patch)
tree87c5cbd2389780c85ce1d618b81cc9af73900d3f
parentf46d0c8d2e4b345a4262d23312ac41bdb5168367 (diff)
parent08c98a6df73ffd0c3bbb0d9798eca59cf4ba7209 (diff)
downloadtangerine-wallet-browser-eec7fcebd528a70b5c8a3571c5b802ced889e626.tar.gz
tangerine-wallet-browser-eec7fcebd528a70b5c8a3571c5b802ced889e626.tar.zst
tangerine-wallet-browser-eec7fcebd528a70b5c8a3571c5b802ced889e626.zip
Merge pull request #5832 from whymarrh/connect-request-notifs
Show Connect Requests count in extension badge
-rw-r--r--app/scripts/background.js4
-rw-r--r--app/scripts/controllers/provider-approval.js8
2 files changed, 8 insertions, 4 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index d577ead41..c75f514d5 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -414,6 +414,7 @@ function setupController (initState, initLangCode) {
controller.messageManager.on('updateBadge', updateBadge)
controller.personalMessageManager.on('updateBadge', updateBadge)
controller.typedMessageManager.on('updateBadge', updateBadge)
+ controller.providerApprovalController.store.on('update', updateBadge)
/**
* Updates the Web Extension's "badge" number, on the little fox in the toolbar.
@@ -425,7 +426,8 @@ function setupController (initState, initLangCode) {
var unapprovedMsgCount = controller.messageManager.unapprovedMsgCount
var unapprovedPersonalMsgs = controller.personalMessageManager.unapprovedPersonalMsgCount
var unapprovedTypedMsgs = controller.typedMessageManager.unapprovedTypedMessagesCount
- var count = unapprovedTxCount + unapprovedMsgCount + unapprovedPersonalMsgs + unapprovedTypedMsgs
+ const pendingProviderRequests = controller.providerApprovalController.store.getState().providerRequests.length
+ var count = unapprovedTxCount + unapprovedMsgCount + unapprovedPersonalMsgs + unapprovedTypedMsgs + pendingProviderRequests
if (count) {
label = String(count)
}
diff --git a/app/scripts/controllers/provider-approval.js b/app/scripts/controllers/provider-approval.js
index 21d7fd22e..53172c069 100644
--- a/app/scripts/controllers/provider-approval.js
+++ b/app/scripts/controllers/provider-approval.js
@@ -22,7 +22,9 @@ class ProviderApprovalController {
this.platform = platform
this.preferencesController = preferencesController
this.publicConfigStore = publicConfigStore
- this.store = new ObservableStore()
+ this.store = new ObservableStore({
+ providerRequests: [],
+ })
if (platform && platform.addMessageListener) {
platform.addMessageListener(({ action = '', force, origin, siteTitle, siteImage }) => {
@@ -103,7 +105,7 @@ class ProviderApprovalController {
*/
approveProviderRequest (origin) {
this.closePopup && this.closePopup()
- const requests = this.store.getState().providerRequests || []
+ const requests = this.store.getState().providerRequests
this.platform && this.platform.sendMessage({
action: 'approve-provider-request',
selectedAddress: this.publicConfigStore.getState().selectedAddress,
@@ -121,7 +123,7 @@ class ProviderApprovalController {
*/
rejectProviderRequest (origin) {
this.closePopup && this.closePopup()
- const requests = this.store.getState().providerRequests || []
+ const requests = this.store.getState().providerRequests
this.platform && this.platform.sendMessage({ action: 'reject-provider-request' }, { active: true })
const providerRequests = requests.filter(request => request.origin !== origin)
this.store.updateState({ providerRequests })