Skip to content

Commit 0727256

Browse files
committed
Add option to MetamaskController.privateSendUpdate for only sending pending patches
1 parent 81d6285 commit 0727256

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

app/scripts/metamask-controller.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7769,12 +7769,18 @@ export default class MetamaskController extends EventEmitter {
77697769
// misc
77707770

77717771
/**
7772-
* A method for emitting the full MetaMask state to all registered listeners.
7772+
* A method for emitting either the full MetaMask state or pending patches to all registered listeners of the 'update' event.
7773+
* This method can be used to force UI updates in response to background actions or events e.g. state updates.
77737774
*
7774-
* @private
7775+
* @param sendFullState - If set to true, the full MetaMask state is sent. If set to false, only pending patches are sent.
7776+
* @see {@link {import('../../ui/store/actions.ts').forceUpdateMetamaskState}} also force-syncs UI state with background state, but in response to UI events or user actions.
77757777
*/
7776-
privateSendUpdate() {
7777-
this.emit('update', this.getState());
7778+
privateSendUpdate(sendFullState = true) {
7779+
if (sendFullState) {
7780+
this.emit('update', this.getState());
7781+
} else {
7782+
this.emit('update');
7783+
}
77787784
}
77797785

77807786
/**

0 commit comments

Comments
 (0)