diff --git a/ui/hooks/metamask-notifications/useNotifications.ts b/ui/hooks/metamask-notifications/useNotifications.ts index 62367cdbe310..9724253a8671 100644 --- a/ui/hooks/metamask-notifications/useNotifications.ts +++ b/ui/hooks/metamask-notifications/useNotifications.ts @@ -54,8 +54,13 @@ export function useListNotifications(): { setLoading(true); setError(null); + const urlParams = new URLSearchParams(window.location.search); + const previewToken = urlParams.get('previewToken'); + try { - const data = await dispatch(fetchAndUpdateMetamaskNotifications()); + const data = await dispatch( + fetchAndUpdateMetamaskNotifications(previewToken ?? undefined), + ); setNotificationsData(data as unknown as Notification[]); return data as unknown as Notification[]; } catch (e) { diff --git a/ui/store/actions.test.js b/ui/store/actions.test.js index d86ea20f845c..22e8db2fa281 100644 --- a/ui/store/actions.test.js +++ b/ui/store/actions.test.js @@ -2258,7 +2258,7 @@ describe('Actions', () => { const fetchAndUpdateMetamaskNotificationsStub = sinon .stub() - .callsFake((cb) => cb()); + .callsFake((_, cb) => cb()); const forceUpdateMetamaskStateStub = sinon.stub().callsFake((cb) => cb()); background.getApi.returns({ @@ -2280,7 +2280,7 @@ describe('Actions', () => { const fetchAndUpdateMetamaskNotificationsStub = sinon .stub() - .callsFake((cb) => cb(error)); + .callsFake((_, cb) => cb(error)); const forceUpdateMetamaskStateStub = sinon .stub() .callsFake((cb) => cb(error)); diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 91e4530035b5..09f819711fcd 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -5423,22 +5423,20 @@ export function updateOnChainTriggersByAccount( /** * Fetches and updates MetaMask notifications. * - * This function sends a request to the background script to fetch the latest notifications and update the state accordingly. - * Upon success, it dispatches an action with type `FETCH_AND_UPDATE_METAMASK_NOTIFICATIONS` to update the Redux state. + * This function sends a request to the background script to fetch the latest notifications. * If the operation encounters an error, it logs the error message and rethrows the error to ensure it is handled appropriately. * + * @param previewToken - Optional preview token for fetching draft feature announcements. * @returns A thunk action that, when dispatched, attempts to fetch and update MetaMask notifications. */ -export function fetchAndUpdateMetamaskNotifications(): ThunkAction< - void, - MetaMaskReduxState, - unknown, - AnyAction -> { +export function fetchAndUpdateMetamaskNotifications( + previewToken?: string, +): ThunkAction { return async () => { try { const response = await submitRequestToBackground( 'fetchAndUpdateMetamaskNotifications', + [previewToken], ); return response; } catch (error) {