Skip to content

Commit 9c6bbd8

Browse files
committed
Guard safe switch of test network
1 parent 23971ce commit 9c6bbd8

File tree

1 file changed

+3
-3
lines changed
  • background/redux-slices

1 file changed

+3
-3
lines changed

background/redux-slices/ui.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,17 @@ export const setSelectedNetwork = createBackgroundAsyncThunk(
400400

401401
export const toggleShowTestNetworks = createBackgroundAsyncThunk(
402402
"ui/toggleShowTestNetworks",
403-
async (value: boolean, { dispatch, getState }) => {
403+
async (updatedValue: boolean, { dispatch, getState }) => {
404404
const state = getState() as RootState
405405

406406
const currentNetwork = state.ui.selectedAccount.network
407407

408408
// If user is on one of the built-in test networks, don't leave them stranded
409-
if (TEST_NETWORK_BY_CHAIN_ID.has(currentNetwork.chainID)) {
409+
if (!updatedValue && TEST_NETWORK_BY_CHAIN_ID.has(currentNetwork.chainID)) {
410410
dispatch(setSelectedNetwork(ETHEREUM))
411411
}
412412

413-
await emitter.emit("toggleShowTestNetworks", value)
413+
await emitter.emit("toggleShowTestNetworks", updatedValue)
414414
},
415415
)
416416

0 commit comments

Comments
 (0)