Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ritave committed Nov 10, 2021
1 parent ce0f540 commit 2f275ef
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 51 deletions.
29 changes: 14 additions & 15 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import ExtensionPlatform from './platforms/extension';
import LocalStore from './lib/local-store';
import ReadOnlyNetworkStore from './lib/network-store';
import createStreamSink from './lib/createStreamSink';
import NotificationManager, { NOTIFICATION_MANAGER_EVENTS } from './lib/notification-manager';
import NotificationManager, {
NOTIFICATION_MANAGER_EVENTS,
} from './lib/notification-manager';
import MetamaskController, {
METAMASK_CONTROLLER_EVENTS,
} from './metamask-controller';
Expand Down Expand Up @@ -477,23 +479,18 @@ function setupController(initState, initLangCode) {

notificationManager.on(
NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,
rejectUnapprovedNotifications
rejectUnapprovedNotifications,
);

function rejectUnapprovedNotifications() {
// TODO(ritave): Return 4001 error to the user,
// instead of just silently dropping
// https://docs.metamask.io/guide/ethereum-provider.html#using-the-provider
// Metamask can open a popup for a login, we need to check if
// we're on a confirmation page
if (controller.isUnlocked()) {
/*
controller.txController.txStateManager.store.getState().transactions.filter((tx) => tx.status === "unapproved")
controller.txController.txStateManager
.getUnapprovedTxList()*/
Object.keys(controller.txController.txStateManager
.getUnapprovedTxList())
.forEach((txId) => controller.txController.txStateManager.setTxStatusRejected(txId));
Object.keys(
controller.txController.txStateManager.getUnapprovedTxList(),
).forEach((txId) =>
controller.txController.txStateManager.setTxStatusRejected(txId),
);
controller.messageManager.messages
.filter((msg) => msg.status === 'unapproved')
.forEach((tx) => controller.messageManager.rejectMsg(tx.id));
Expand All @@ -509,9 +506,11 @@ function setupController(initState, initLangCode) {
controller.typedMessageManager.messages
.filter((msg) => msg.status === 'unapproved')
.forEach((tx) => controller.decryptMessageManager.rejectMsg(tx.id));
Object.keys(controller.approvalController.state.pendingApprovals)
.forEach((approvalId) => controller.approvalController.reject(approvalId, new Error()));

Object.keys(
controller.approvalController.state.pendingApprovals,
).forEach((approvalId) =>
controller.approvalController.reject(approvalId, new Error()),
);

updateBadge();
}
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/lib/notification-manager.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import ExtensionPlatform from '../platforms/extension';
import extension from 'extensionizer';
import EventEmitter from 'safe-event-emitter';
import ExtensionPlatform from '../platforms/extension';

const NOTIFICATION_HEIGHT = 620;
const NOTIFICATION_WIDTH = 360;

export const NOTIFICATION_MANAGER_EVENTS = {
POPUP_CLOSED: 'onPopupClosed',
}
};

export default class NotificationManager extends EventEmitter {
/**
Expand Down
1 change: 0 additions & 1 deletion ui/components/app/dropdowns/network-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function mapDispatchToProps(dispatch) {
}),
);
},
hideTestNetMessage: () => dispatch(actions.hideTestNetMessage()),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export default class SignatureRequestOriginal extends Component {
this._removeBeforeUnload();
};

_beforeUnload = (event) => {
const { clearConfirmTransaction, cancel } = this.props;
_beforeUnload = (_) => {
const { metricsEvent } = this.context;
metricsEvent({
eventOpts: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default class SignatureRequest extends PureComponent {
name: PropTypes.string,
}).isRequired,
isLedgerWallet: PropTypes.bool,
clearConfirmTransaction: PropTypes.func.isRequired,
cancel: PropTypes.func.isRequired,
sign: PropTypes.func.isRequired,
hardwareWalletRequiresConnection: PropTypes.func.isRequired,
Expand All @@ -34,10 +33,8 @@ export default class SignatureRequest extends PureComponent {
}
}

_beforeUnload = (event) => {
_beforeUnload = (_) => {
const {
clearConfirmTransaction,
cancel,
txData: { type },
} = this.props;
const { metricsEvent } = this.context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ export default class ConfirmDecryptMessage extends Component {
};

_beforeUnload = async (event) => {
const {
clearConfirmTransaction,
cancelDecryptMessage,
txData,
} = this.props;
const { cancelDecryptMessage, txData } = this.props;
const { metricsEvent } = this.context;
await cancelDecryptMessage(txData, event);
metricsEvent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export default class ConfirmEncryptionPublicKey extends Component {
};

_beforeUnload = async (event) => {
const {
clearConfirmTransaction,
cancelEncryptionPublicKey,
txData,
} = this.props;
const { cancelEncryptionPublicKey, txData } = this.props;
const { metricsEvent } = this.context;
await cancelEncryptionPublicKey(txData, event);
metricsEvent({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app';
import { getEnvironmentType } from '../../../app/scripts/lib/util';
import ConfirmPageContainer from '../../components/app/confirm-page-container';
import { isBalanceSufficient } from '../send/send.utils';
import {
Expand Down Expand Up @@ -801,10 +799,6 @@ export default class ConfirmTransactionBase extends Component {
};
}

_beforeUnload = () => {
const { txData: { id } = {}, cancelTransaction } = this.props;
};

_beforeUnloadForGasPolling = () => {
this._isMounted = false;
if (this.state.pollingToken) {
Expand All @@ -814,9 +808,6 @@ export default class ConfirmTransactionBase extends Component {
};

_removeBeforeUnload = () => {
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
window.removeEventListener('beforeunload', this._beforeUnload);
}
window.removeEventListener('beforeunload', this._beforeUnloadForGasPolling);
};

Expand All @@ -840,10 +831,6 @@ export default class ConfirmTransactionBase extends Component {
},
});

if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
window.addEventListener('beforeunload', this._beforeUnload);
}

getNextNonce();
if (toAddress) {
tryReverseResolveAddress(toAddress);
Expand Down
4 changes: 0 additions & 4 deletions ui/pages/settings/advanced-tab/advanced-tab.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
turnThreeBoxSyncingOnAndInitialize,
setUseNonceField,
setIpfsGateway,
setLedgerTransportPreference,
setDismissSeedBackUpReminder,
} from '../../../store/actions';
import { getPreferences } from '../../../selectors';
Expand Down Expand Up @@ -87,9 +86,6 @@ export const mapDispatchToProps = (dispatch) => {
setIpfsGateway: (value) => {
return dispatch(setIpfsGateway(value));
},
setLedgerTransportPreference: (value) => {
return dispatch(setLedgerTransportPreference(value));
},
setDismissSeedBackUpReminder: (value) => {
return dispatch(setDismissSeedBackUpReminder(value));
},
Expand Down

0 comments on commit 2f275ef

Please sign in to comment.