-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add manage tokens, closes #5643 #5896
Conversation
b75a018
to
2c46b31
Compare
I downloaded the preview and am noticing all my Runes are hidden by default, even though we support USD prices on Runes. Ideally we would filter out low-quality Runes but keep ones that have higher value in wallets such as $DOG (DOG GO TO MOON) |
I just noticed that even when enabling Runes, they do not show in the asset list. So Runes are always hidden and SRC20 are always shown 😉 |
2c46b31
to
b861945
Compare
@brandonmarshall-tm fixed |
Confirming I am able to hide SRC20 and unhide Runes. All Runes are still hidden by default, though, which I don't think is our intention |
1430dd0
to
0861792
Compare
Looks good to me! |
0861792
to
33d8d66
Compare
src/app/components/crypto-asset-item/crypto-asset-item-toggle.layout.tsx
Outdated
Show resolved
Hide resolved
src/app/features/asset-list/stacks/stx-crypo-asset-item/stx-crypto-asset-item.tsx
Outdated
Show resolved
Hide resolved
if (assetRightElementVariant === 'toggle') { | ||
return ( | ||
<CryptoAssetItemToggleLayout | ||
key={key} | ||
captionLeft={captionLeft} | ||
icon={icon} | ||
titleLeft={titleLeft} | ||
assetId={token.info.symbol} | ||
isCheckedByDefault={isTokenEnabled({ tokenId: token.info.symbol, preEnabledTokensIds })} | ||
/> | ||
); | ||
} | ||
return ( | ||
<CryptoAssetItemLayout | ||
availableBalance={token.balance.availableBalance} | ||
captionLeft={captionLeft} | ||
key={key} | ||
icon={<Src20AvatarIcon />} | ||
titleLeft={titleLeft} | ||
isPrivate={isPrivate} | ||
dataTestId={token.info.symbol} | ||
/> | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach seems a coupled to me. Rather than "baking in" the toggleable functionality to every single list, shouldn't we compose together a new view that has the toggle functionnality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored this, so it's in sep component
name: 'manageTokens', | ||
initialState: manageTokensAdapter.getInitialState(), | ||
reducers: { | ||
setToken(state, action: PayloadAction<{ id: string; enabled: boolean; accountIndex: number }>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we model over the action/event taking place? https://redux.js.org/style-guide/#model-actions-as-events-not-setters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree here, trying to understand some of the changes, is it nec to have manage
in the naming? Isn't a slice of state always managing
state, would just tokensSlice
be sufficient here to describe it? I think there might be a way to make what is happening here more clear, like what is setToken
doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manageToken more refer to a feature itself, not like managing tokens state slice
33d8d66
to
fe2538d
Compare
bcbd817
to
f46def1
Compare
@alter-eggo I think I was looking at a different version when I tested this in the weekend. This is looking good now. I would prefer the settings to be the same for all accounts instead of different per account. But as you said that can be an enhancement for later so that this can go live as it is now. Should there be an option to easily hide/unhide all (except gas tokens) too? The color difference between on and off is very small, that makes the color difference less helpful to see the difference. |
@314159265359879 we can add "all" switcher as further enhancement as well 👍 let's create sep issue for these ideas?
hm, as for me it looks ok, wdyt @fabric-8? |
updateTokenEnableState( | ||
state, | ||
action: PayloadAction<{ id: string; enabled: boolean; accountIndex: number }> | ||
) { | ||
manageTokensAdapter.setOne(state, { | ||
id: action.payload.id, | ||
enabled: action.payload.enabled, | ||
accountIndex: action.payload.accountIndex, | ||
}); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateTokenEnableState( | |
state, | |
action: PayloadAction<{ id: string; enabled: boolean; accountIndex: number }> | |
) { | |
manageTokensAdapter.setOne(state, { | |
id: action.payload.id, | |
enabled: action.payload.enabled, | |
accountIndex: action.payload.accountIndex, | |
}); | |
}, | |
updateTokenEnableState( | |
state, | |
action: PayloadAction<{ id: string; enabled: boolean; accountIndex: number }> | |
) { | |
manageTokensAdapter.setOne(state, { | |
id: action.payload.id, | |
enabled: action.payload.enabled, | |
accountIndex: action.payload.accountIndex, | |
}); | |
}, |
This still kinda violates the "map to user actions, not state setters" practice. I'd go for something like userTogglesTokenVisibility
etc
f46def1
to
f7e50fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @alter-eggo 👍
Great stuff — Let's revisit the toggle component states separately, I think it's ok for now to move on |
This pr adds:
@cbadawi thanks a lot for working on this feature!