From 17a79522f5ef0e20fc44d9cbbd12f65f8d4e6914 Mon Sep 17 00:00:00 2001 From: Ali Haghighatkhah Date: Tue, 15 Nov 2022 15:06:35 +0100 Subject: [PATCH] Remove the obsolete timerReset action --- src/modules/auth/store/action.js | 9 --------- src/modules/auth/store/actionTypes.js | 1 - .../components/bars/sideBar/autoSignOut/warning.js | 5 ----- .../components/bars/sideBar/autoSignOut/warning.test.js | 6 ------ src/modules/dpos/validator/store/actions/voting.js | 2 -- .../components/SettingDialog/settingDialog.test.js | 3 --- src/modules/settings/manager/SettingsManager.js | 2 -- src/modules/transaction/store/actions.test.js | 8 -------- src/modules/wallet/store/actionTypes.js | 1 - 9 files changed, 37 deletions(-) diff --git a/src/modules/auth/store/action.js b/src/modules/auth/store/action.js index 4718339ba4..2cdc396fd8 100644 --- a/src/modules/auth/store/action.js +++ b/src/modules/auth/store/action.js @@ -1,15 +1,6 @@ /* eslint-disable max-lines */ import actionTypes from './actionTypes'; -/** - * Fires an action to reset the account automatic sign out timer - * @param {Date} date - Current date - */ -export const timerReset = () => ({ - type: actionTypes.timerReset, - data: new Date(), -}); - /** export const accountLoading = () => ({ type: actionTypes.accountLoading, }); */ diff --git a/src/modules/auth/store/actionTypes.js b/src/modules/auth/store/actionTypes.js index a1fad5416d..436c1ecb51 100644 --- a/src/modules/auth/store/actionTypes.js +++ b/src/modules/auth/store/actionTypes.js @@ -5,7 +5,6 @@ const actionTypes = { accountUpdated: 'ACCOUNT_UPDATED', secondPassphraseStored: 'SECOND_PASSPHRASE_STORED', secondPassphraseRemoved: 'SECOND_PASSPHRASE_REMOVED', - timerReset: 'TIMER_RESET', }; export default actionTypes; diff --git a/src/modules/common/components/bars/sideBar/autoSignOut/warning.js b/src/modules/common/components/bars/sideBar/autoSignOut/warning.js index c26e080651..ea2b3962c7 100644 --- a/src/modules/common/components/bars/sideBar/autoSignOut/warning.js +++ b/src/modules/common/components/bars/sideBar/autoSignOut/warning.js @@ -2,9 +2,7 @@ import React, { useState } from 'react'; import Countdown from 'react-countdown'; import { toast } from 'react-toastify'; -import { useDispatch } from 'react-redux'; import { withTranslation } from 'react-i18next'; -import { timerReset } from '@auth/store/action'; import { timeOutWarningId } from 'src/utils/toasts'; import account from '@wallet/configuration/constants'; import styles from './autoSignOut.css'; @@ -12,12 +10,9 @@ import styles from './autoSignOut.css'; const TimeOutToast = ({ t, upDateCount, completed, expireTime, }) => { - const dispatch = useDispatch(); - const onResetTime = () => { if (new Date().getTime() < new Date(expireTime).getTime()) { upDateCount(); - dispatch(timerReset()); } }; diff --git a/src/modules/common/components/bars/sideBar/autoSignOut/warning.test.js b/src/modules/common/components/bars/sideBar/autoSignOut/warning.test.js index 313cf25cdf..b07e7e7354 100644 --- a/src/modules/common/components/bars/sideBar/autoSignOut/warning.test.js +++ b/src/modules/common/components/bars/sideBar/autoSignOut/warning.test.js @@ -1,6 +1,5 @@ import React from 'react'; import { mount } from 'enzyme'; -import { timerReset } from '@auth/store/action'; import account from '@wallet/configuration/constants'; import Warning from './warning'; @@ -8,10 +7,6 @@ jest.mock('react-toastify', () => ({ toast: (component) => (component), })); -jest.mock('@auth/store/action', () => ({ - timerReset: jest.fn(), -})); - describe('Warning', () => { const date = Date.now(); const expireTime = date + account.lockDuration; @@ -37,6 +32,5 @@ describe('Warning', () => { wrapper.update(); expect(wrapper).not.toBeEmptyRender(); wrapper.find('.reset-time-button').simulate('click'); - expect(timerReset).toHaveBeenCalled(); }); }); diff --git a/src/modules/dpos/validator/store/actions/voting.js b/src/modules/dpos/validator/store/actions/voting.js index 77ce748eb1..385980d083 100644 --- a/src/modules/dpos/validator/store/actions/voting.js +++ b/src/modules/dpos/validator/store/actions/voting.js @@ -2,7 +2,6 @@ import to from 'await-to-js'; // import { tokenMap } from '@token/fungible/consts/tokens'; import { selectActiveTokenAccount } from 'src/redux/selectors'; import { signTransaction } from '@transaction/api'; -import { timerReset } from '@auth/store/action'; import txActionTypes from '@transaction/store/actionTypes'; import { joinModuleAndCommand } from '@transaction/utils'; import { getVotes } from '../../api'; @@ -92,7 +91,6 @@ export const votesSubmitted = }); } else { dispatch({ type: actionTypes.votesSubmitted }); - dispatch(timerReset()); dispatch({ type: txActionTypes.transactionCreatedSuccess, data: tx, diff --git a/src/modules/settings/components/SettingDialog/settingDialog.test.js b/src/modules/settings/components/SettingDialog/settingDialog.test.js index 23bb560f34..5b31b2d538 100644 --- a/src/modules/settings/components/SettingDialog/settingDialog.test.js +++ b/src/modules/settings/components/SettingDialog/settingDialog.test.js @@ -28,7 +28,6 @@ describe('Setting', () => { const props = { transactions: { pending: [] }, account: { token: 'LSK', passphrase: 'sample_passphrase' }, - timerReset: jest.fn(), settingsUpdated: jest.fn(), settings, t, @@ -65,7 +64,6 @@ describe('Setting', () => { // it('should change autolog setting when clicking on checkbox', () => { // wrapper.find('.autoLog input').at(0).simulate('change', { target: { name: 'autoLog' } }); - // expect(props.timerReset).toBeCalled(); // }); // it('should change discreet mode setting when clicking on checkbox', () => { @@ -112,7 +110,6 @@ describe('Setting', () => { // wrapper.find('.autoLog input').at(0).simulate('change', { target: { name: 'autoLog' } }); - // expect(props.timerReset).toBeCalled(); // }); // }); }); diff --git a/src/modules/settings/manager/SettingsManager.js b/src/modules/settings/manager/SettingsManager.js index fb0337acf8..67bbc935fe 100644 --- a/src/modules/settings/manager/SettingsManager.js +++ b/src/modules/settings/manager/SettingsManager.js @@ -3,7 +3,6 @@ import { connect } from 'react-redux'; import { withTranslation } from 'react-i18next'; import { selectActiveTokenAccount } from 'src/redux/selectors'; import { settingsUpdated } from 'src/redux/actions'; -import { timerReset } from '@auth/store/action'; import SettingDialog from '../components/SettingDialog'; const mapStateToProps = state => ({ @@ -13,7 +12,6 @@ const mapStateToProps = state => ({ }); const mapDispatchToProps = { - timerReset, settingsUpdated, }; diff --git a/src/modules/transaction/store/actions.test.js b/src/modules/transaction/store/actions.test.js index bd1b149100..fc1f28fc38 100644 --- a/src/modules/transaction/store/actions.test.js +++ b/src/modules/transaction/store/actions.test.js @@ -253,17 +253,12 @@ describe.skip('actions: transactions', () => { type: actionTypes.broadcastedTransactionSuccess, data: sampleTransaction, }; - const lastExpectedAction = { - type: walletActionTypes.timerReset, - data: new Date(), - }; // Act await transactionBroadcasted(sampleTransaction)(dispatch, getState); // Assert expect(dispatch).toHaveBeenCalledWith(expectedAction); - expect(dispatch).toHaveBeenLastCalledWith(lastExpectedAction); }); it('should dispatch broadcastedTransactionError action when broadcast has an error', async () => { @@ -301,7 +296,6 @@ describe.skip('actions: transactions', () => { // type: actionTypes.pendingTransactionAdded, // data: { ...transformedAccountTransaction, isPending: true }, // }; - const expectedAction3 = { data: expect.anything(), type: walletActionTypes.timerReset }; // Act await transactionBroadcasted(sampleTransaction)(dispatch, getState); @@ -309,8 +303,6 @@ describe.skip('actions: transactions', () => { // Assert expect(httpApi).toHaveBeenCalled(); expect(dispatch).toHaveBeenNthCalledWith(1, expectedAction1); - // expect(dispatch).toHaveBeenNthCalledWith(2, expectedAction2); - expect(dispatch).toHaveBeenNthCalledWith(3, expectedAction3); }); }); diff --git a/src/modules/wallet/store/actionTypes.js b/src/modules/wallet/store/actionTypes.js index a1fad5416d..436c1ecb51 100644 --- a/src/modules/wallet/store/actionTypes.js +++ b/src/modules/wallet/store/actionTypes.js @@ -5,7 +5,6 @@ const actionTypes = { accountUpdated: 'ACCOUNT_UPDATED', secondPassphraseStored: 'SECOND_PASSPHRASE_STORED', secondPassphraseRemoved: 'SECOND_PASSPHRASE_REMOVED', - timerReset: 'TIMER_RESET', }; export default actionTypes;