@@ -147,10 +147,9 @@ function PrivacyPolicyToast() {
147147
148148 if ( ! newPrivacyPolicyToastShownDate ) {
149149 setNewPrivacyPolicyToastShownDate ( Date . now ( ) ) ;
150- return undefined ;
151150 }
152151
153- toast ( {
152+ const toastId = toast ( {
154153 severity : 'default' ,
155154 title : t ( 'newPrivacyPolicyTitle' ) ,
156155 actionButtonLabel : t ( 'newPrivacyPolicyActionButton' ) ,
@@ -167,7 +166,9 @@ function PrivacyPolicyToast() {
167166 } ) ;
168167
169168 return ( ) => {
170- toast . dismiss ( ) ;
169+ if ( toastId ) {
170+ toast . dismiss ( toastId ) ;
171+ }
171172 } ;
172173 } , [ newPrivacyPolicyToastShownDate , showPrivacyPolicyToast , t ] ) ;
173174
@@ -210,7 +211,7 @@ function PermittedNetworkToast() {
210211 return undefined ;
211212 }
212213
213- toast ( {
214+ const toastId = toast ( {
214215 severity : 'default' ,
215216 title : t ( 'permittedChainToastUpdate' , [
216217 getURLHost ( activeTabOrigin ) ,
@@ -233,7 +234,9 @@ function PermittedNetworkToast() {
233234 } ) ;
234235
235236 return ( ) => {
236- toast . dismiss ( ) ;
237+ if ( toastId ) {
238+ toast . dismiss ( toastId ) ;
239+ }
237240 } ;
238241 } , [
239242 activeTabOrigin ,
@@ -261,7 +264,7 @@ function InfuraSwitchToast() {
261264 return undefined ;
262265 }
263266
264- toast ( {
267+ const toastId = toast ( {
265268 severity : 'success' ,
266269 title : t ( 'updatedToMetaMaskDefault' ) ,
267270 startAccessory : (
@@ -272,7 +275,9 @@ function InfuraSwitchToast() {
272275 } ) ;
273276
274277 return ( ) => {
275- toast . dismiss ( ) ;
278+ if ( toastId ) {
279+ toast . dismiss ( toastId ) ;
280+ }
276281 } ;
277282 } , [ dispatch , showInfuraSwitchToast , t ] ) ;
278283
@@ -351,7 +356,7 @@ function ShieldPausedToast() {
351356 setShieldPausedToastLastClickedOrClosed ( Date . now ( ) ) ;
352357 } ;
353358
354- toast ( {
359+ const toastId = toast ( {
355360 severity : 'danger' ,
356361 title : t ( 'shieldPaymentPaused' ) ,
357362 description : t ( descriptionText ) ,
@@ -368,7 +373,9 @@ function ShieldPausedToast() {
368373 } ) ;
369374
370375 return ( ) => {
371- toast . dismiss ( ) ;
376+ if ( toastId ) {
377+ toast . dismiss ( toastId ) ;
378+ }
372379 } ;
373380 } , [
374381 actionText ,
@@ -408,7 +415,7 @@ function ShieldEndingToast() {
408415 return undefined ;
409416 }
410417
411- toast ( {
418+ const toastId = toast ( {
412419 severity : 'default' ,
413420 title : t ( 'shieldCoverageEnding' ) ,
414421 description : t ( 'shieldCoverageEndingDescription' , [
@@ -430,7 +437,9 @@ function ShieldEndingToast() {
430437 } ) ;
431438
432439 return ( ) => {
433- toast . dismiss ( ) ;
440+ if ( toastId ) {
441+ toast . dismiss ( toastId ) ;
442+ }
434443 } ;
435444 } , [
436445 isSubscriptionEndingSoon ,
@@ -497,7 +506,7 @@ function StorageErrorToast() {
497506 setIsDismissed ( true ) ;
498507 } ;
499508
500- toast ( {
509+ const toastId = toast ( {
501510 severity : 'danger' ,
502511 'data-testid' : 'storage-error-toast' ,
503512 startAccessory : (
@@ -515,7 +524,9 @@ function StorageErrorToast() {
515524 } ) ;
516525
517526 return ( ) => {
518- toast . dismiss ( ) ;
527+ if ( toastId ) {
528+ toast . dismiss ( toastId ) ;
529+ }
519530 } ;
520531 } , [
521532 description ,
@@ -545,7 +556,7 @@ function SidePanelMigrationToast() {
545556 return undefined ;
546557 }
547558
548- toast ( {
559+ const toastId = toast ( {
549560 severity : 'default' ,
550561 'data-testid' : 'side-panel-migration-toast' ,
551562 startAccessory : (
@@ -571,7 +582,9 @@ function SidePanelMigrationToast() {
571582 } ) ;
572583
573584 return ( ) => {
574- toast . dismiss ( ) ;
585+ if ( toastId ) {
586+ toast . dismiss ( toastId ) ;
587+ }
575588 } ;
576589 } , [ dispatch , isSidePanel , showSidePanelMigrationToast , t ] ) ;
577590
0 commit comments