mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
0c203d0518
* refactoring signature-request and adding test coverage * adding storybook and removing the reduntant files: * adding new components from * replacing <SiteOrigin/> with <TagUrl/> * updating review comments from Jyoti and George * adding the hook * refactoring in the changes from #18770 MMI PR * adding new hook for the MMISign changes * updating lavamoat * updating lavamoat * removing a commeted line * updating the sign check with accountType conditional * fixing build issues * updating the review comments on the hooks * updating signatureRequestHeader * lint fix * fixing test failure * lint fix * updating review comments * adding the renamed hook * updating the origin url * fixing test failure * migrating changes from #19184 * updating snapshot * fixing e2e failure * fixing e2e failure * addressing review comments from Joao * migrating chnages from #19892 * moving shallowEqual inside of mmi build * migrating changes from #19881 * fixing build failure * migrating changes from #19949 * migrating changes from #19468 * updating snapshot * updating snapshot * updating QA review comments * fixing full screen height issue from develop * migrating changes from #20083 * fixing snapshot
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import { useDispatch, useSelector } from 'react-redux';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { valuesFor } from '../helpers/utils/util';
|
|
import { showModal, rejectAllMessages } from '../store/actions';
|
|
import { clearConfirmTransaction } from '../ducks/confirm-transaction/confirm-transaction.duck';
|
|
import { getMostRecentOverviewPage } from '../ducks/history/history';
|
|
import {
|
|
getTotalUnapprovedMessagesCount,
|
|
unconfirmedMessagesHashSelector,
|
|
} from '../selectors';
|
|
|
|
export function useRejectTransactionModal() {
|
|
const dispatch = useDispatch();
|
|
const history = useHistory();
|
|
const mostRecentOverviewPage = useSelector(getMostRecentOverviewPage);
|
|
const unapprovedMessagesCount = useSelector(getTotalUnapprovedMessagesCount);
|
|
const unconfirmedMessagesList = useSelector(unconfirmedMessagesHashSelector);
|
|
|
|
const handleCancelAll = () => {
|
|
dispatch(
|
|
showModal({
|
|
name: 'REJECT_TRANSACTIONS',
|
|
onSubmit: async () => {
|
|
await dispatch(rejectAllMessages(valuesFor(unconfirmedMessagesList)));
|
|
dispatch(clearConfirmTransaction());
|
|
history.push(mostRecentOverviewPage);
|
|
},
|
|
unapprovedTxCount: unapprovedMessagesCount,
|
|
isRequestType: true,
|
|
}),
|
|
);
|
|
};
|
|
|
|
return { handleCancelAll };
|
|
}
|