Change network without window refresh (#825)
* remove RSK as support network * completely remove RSK * change network without window refresh * fix saga tests * fix import
This commit is contained in:
parent
a2eb2021cd
commit
b8b0cdece3
|
@ -20,7 +20,7 @@ export class UnlockHeader extends React.Component<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public componentDidUpdate(prevProps: Props) {
|
public componentDidUpdate(prevProps: Props) {
|
||||||
if (this.props.wallet && this.props.wallet !== prevProps.wallet) {
|
if (this.props.wallet !== prevProps.wallet) {
|
||||||
this.setState({ isExpanded: !this.state.isExpanded });
|
this.setState({ isExpanded: !this.state.isExpanded });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ import { IWallet, Web3Wallet } from 'libs/wallet';
|
||||||
import { getWalletInst } from 'selectors/wallet';
|
import { getWalletInst } from 'selectors/wallet';
|
||||||
import { TypeKeys as WalletTypeKeys } from 'actions/wallet/constants';
|
import { TypeKeys as WalletTypeKeys } from 'actions/wallet/constants';
|
||||||
import { State as ConfigState, INITIAL_STATE as configInitialState } from 'reducers/config';
|
import { State as ConfigState, INITIAL_STATE as configInitialState } from 'reducers/config';
|
||||||
|
import { resetWallet } from 'actions/wallet';
|
||||||
|
import { reset as resetTransaction } from 'actions/transaction';
|
||||||
|
|
||||||
export const getConfig = (state: AppState): ConfigState => state.config;
|
export const getConfig = (state: AppState): ConfigState => state.config;
|
||||||
|
|
||||||
|
@ -173,7 +175,8 @@ export function* handleNodeChangeIntent(action: ChangeNodeIntentAction): SagaIte
|
||||||
|
|
||||||
// if there's no wallet, do not reload as there's no component state to resync
|
// if there's no wallet, do not reload as there's no component state to resync
|
||||||
if (currentWallet && currentConfig.network !== actionConfig.network) {
|
if (currentWallet && currentConfig.network !== actionConfig.network) {
|
||||||
yield call(reload);
|
yield put(resetWallet());
|
||||||
|
yield put(resetTransaction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {
|
||||||
pollOfflineStatus,
|
pollOfflineStatus,
|
||||||
handlePollOfflineStatus,
|
handlePollOfflineStatus,
|
||||||
handleNodeChangeIntent,
|
handleNodeChangeIntent,
|
||||||
reload,
|
|
||||||
unsetWeb3Node,
|
unsetWeb3Node,
|
||||||
unsetWeb3NodeOnWalletEvent,
|
unsetWeb3NodeOnWalletEvent,
|
||||||
equivalentNodeOrDefault
|
equivalentNodeOrDefault
|
||||||
|
@ -26,7 +25,8 @@ import { Web3Wallet } from 'libs/wallet';
|
||||||
import { RPCNode } from 'libs/nodes';
|
import { RPCNode } from 'libs/nodes';
|
||||||
import { showNotification } from 'actions/notifications';
|
import { showNotification } from 'actions/notifications';
|
||||||
import { translateRaw } from 'translations';
|
import { translateRaw } from 'translations';
|
||||||
|
import { resetWallet } from 'actions/wallet';
|
||||||
|
import { reset as resetTransaction } from 'actions/transaction';
|
||||||
// init module
|
// init module
|
||||||
configuredStore.getState();
|
configuredStore.getState();
|
||||||
|
|
||||||
|
@ -214,7 +214,8 @@ describe('handleNodeChangeIntent*', () => {
|
||||||
|
|
||||||
it('should call reload if wallet exists and network is new', () => {
|
it('should call reload if wallet exists and network is new', () => {
|
||||||
data.clone2 = data.gen.clone();
|
data.clone2 = data.gen.clone();
|
||||||
expect(data.clone2.next(truthyWallet).value).toEqual(call(reload));
|
expect(data.clone2.next(truthyWallet).value).toEqual(put(resetWallet()));
|
||||||
|
expect(data.clone2.next(truthyWallet).value).toEqual(put(resetTransaction()));
|
||||||
expect(data.clone2.next().done).toEqual(true);
|
expect(data.clone2.next().done).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue