mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Use initState to avoid type-checking providerRequests in state
This commit is contained in:
parent
f46d0c8d2e
commit
826eb82ed8
@ -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 })
|
||||
|
Loading…
Reference in New Issue
Block a user