Skip to content

Commit

Permalink
fix: chains not updated after delted
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Jul 16, 2024
1 parent ea484e7 commit a16edcb
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { useTheme } from "next-themes";
import Select, { MultiValue, SingleValue } from "react-select";
import { Chain } from "viem";
import { mainnet } from "viem/chains";
import { AddCustomChainModal, CustomOption, OtherChainsModal } from "~~/components/NetworksDropdown";
import { useGlobalState } from "~~/services/store/store";

Expand All @@ -23,9 +24,10 @@ export const NetworksDropdown = ({ onChange }: { onChange: (options: any) => any
const [groupedOptionsState, setGroupedOptionsState] = useState(initialGroupedOptions);
const [selectedOption, setSelectedOption] = useState<SingleValue<Options>>(initialGroupedOptions.mainnet.options[0]);

const { addCustomChain, removeChain } = useGlobalState(state => ({
const { addCustomChain, removeChain, resetTargetNetwork } = useGlobalState(state => ({
addCustomChain: state.addChain,
removeChain: state.removeChain,
resetTargetNetwork: () => state.setTargetNetwork(mainnet),
}));

const seeOtherChainsModalRef = useRef<HTMLDialogElement>(null);
Expand Down Expand Up @@ -108,6 +110,7 @@ export const NetworksDropdown = ({ onChange }: { onChange: (options: any) => any

removeChain(chainId);
removeChainFromLocalStorage(chainId);
resetTargetNetwork();

const newGroupedOptions = { ...groupedOptionsState };
const groupName = option.testnet ? "testnet" : "mainnet";
Expand Down

0 comments on commit a16edcb

Please sign in to comment.