Skip to content

Commit

Permalink
Add token toggling for manage mode in ext popup
Browse files Browse the repository at this point in the history
  • Loading branch information
serg-plusplus committed Aug 12, 2022
1 parent def3f44 commit 6cf9d53
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/app/components/screens/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAtom, useAtomValue } from "jotai";
import classNames from "clsx";
import Masonry from "lib/react-masonry/Masonry";

import { AccountAsset, AccountNFT, TokenType } from "core/types";
import { AccountAsset, AccountNFT, TokenStatus, TokenType } from "core/types";
import * as repo from "core/repo";

import {
Expand Down Expand Up @@ -120,6 +120,7 @@ const TokenList: FC = () => {
}, []);

const {
currentAccount,
isNftsSelected,
searchValue,
setSearchValue,
Expand Down Expand Up @@ -149,9 +150,29 @@ const TokenList: FC = () => {
[setSearchValue, setManageModeEnabled, setTokenType]
);

const handleNFTSelect = useCallback((nft: AccountNFT) => {
console.info({ nft });
}, []);
const handleNFTSelect = useCallback(
async (token: AccountNFT) => {
if (manageModeEnabled) {
try {
await repo.accountTokens.put(
{
...token,
status:
token.status === TokenStatus.Enabled
? TokenStatus.Disabled
: TokenStatus.Enabled,
},
[token.chainId, currentAccount.address, token.tokenSlug].join("_")
);
} catch (e) {
console.error(e);
}
} else {
console.info({ token });
}
},
[manageModeEnabled, currentAccount.address]
);

const renderNFTCard = useCallback(
(nft: AccountNFT, i: number) => (
Expand Down

0 comments on commit 6cf9d53

Please sign in to comment.