Merge pull request #5832 from whymarrh/connect-request-notifs

Show Connect Requests count in extension badge
feature/default_network_editable
Whymarrh Whitby 6 years ago committed by GitHub
commit eec7fcebd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/scripts/background.js
  2. 8
      app/scripts/controllers/provider-approval.js

@ -414,6 +414,7 @@ function setupController (initState, initLangCode) {
controller.messageManager.on('updateBadge', updateBadge) controller.messageManager.on('updateBadge', updateBadge)
controller.personalMessageManager.on('updateBadge', updateBadge) controller.personalMessageManager.on('updateBadge', updateBadge)
controller.typedMessageManager.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. * 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 unapprovedMsgCount = controller.messageManager.unapprovedMsgCount
var unapprovedPersonalMsgs = controller.personalMessageManager.unapprovedPersonalMsgCount var unapprovedPersonalMsgs = controller.personalMessageManager.unapprovedPersonalMsgCount
var unapprovedTypedMsgs = controller.typedMessageManager.unapprovedTypedMessagesCount 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) { if (count) {
label = String(count) label = String(count)
} }

@ -22,7 +22,9 @@ class ProviderApprovalController {
this.platform = platform this.platform = platform
this.preferencesController = preferencesController this.preferencesController = preferencesController
this.publicConfigStore = publicConfigStore this.publicConfigStore = publicConfigStore
this.store = new ObservableStore() this.store = new ObservableStore({
providerRequests: [],
})
if (platform && platform.addMessageListener) { if (platform && platform.addMessageListener) {
platform.addMessageListener(({ action = '', force, origin, siteTitle, siteImage }) => { platform.addMessageListener(({ action = '', force, origin, siteTitle, siteImage }) => {
@ -103,7 +105,7 @@ class ProviderApprovalController {
*/ */
approveProviderRequest (origin) { approveProviderRequest (origin) {
this.closePopup && this.closePopup() this.closePopup && this.closePopup()
const requests = this.store.getState().providerRequests || [] const requests = this.store.getState().providerRequests
this.platform && this.platform.sendMessage({ this.platform && this.platform.sendMessage({
action: 'approve-provider-request', action: 'approve-provider-request',
selectedAddress: this.publicConfigStore.getState().selectedAddress, selectedAddress: this.publicConfigStore.getState().selectedAddress,
@ -121,7 +123,7 @@ class ProviderApprovalController {
*/ */
rejectProviderRequest (origin) { rejectProviderRequest (origin) {
this.closePopup && this.closePopup() 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 }) this.platform && this.platform.sendMessage({ action: 'reject-provider-request' }, { active: true })
const providerRequests = requests.filter(request => request.origin !== origin) const providerRequests = requests.filter(request => request.origin !== origin)
this.store.updateState({ providerRequests }) this.store.updateState({ providerRequests })

Loading…
Cancel
Save