Skip to content

Commit

Permalink
separate pinning and unpinning
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiKJha committed Dec 11, 2023
1 parent b95cb42 commit afa7237
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@ export const AccountListItemMenu = ({
};
}, [handleClickOutside]);

const handlePinningToggle = (address, pin) => {
const updatedPinnedAccountList = pin
? pinnedAccountList.filter((item) => item !== address)
: [...pinnedAccountList, address];
const handlePinning = (address) => {
const updatedPinnedAccountList = [...pinnedAccountList, address];
dispatch(updateAccountsList(updatedPinnedAccountList));
};

const handleUnpinning = (address) => {
const updatedPinnedAccountList = pinnedAccountList.filter(
(item) => item !== address,
);
dispatch(updateAccountsList(updatedPinnedAccountList));
};

Expand Down Expand Up @@ -163,7 +167,9 @@ export const AccountListItemMenu = ({
<MenuItem
data-testid="account-list-menu-pin"
onClick={() => {
handlePinningToggle(identity.address, isPinned);
isPinned
? handleUnpinning(identity.address)
: handlePinning(identity.address);
onClose();
}}
iconName={isPinned ? IconName.Unpin : IconName.Pin}
Expand Down

0 comments on commit afa7237

Please sign in to comment.