-
Notifications
You must be signed in to change notification settings - Fork 26
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
Hide assets from views #1797
base: release/5.28.0
Are you sure you want to change the base?
Hide assets from views #1797
Conversation
…nsion settings duck state
soroswapTokens, | ||
networkDetails, | ||
]); | ||
const goBack = () => { |
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.
Now that we need to fetch balances here, this pattern suffers more from the stale store state so this resets the store in order for the state to be correct on the Account page once navigation lands there. I noted a possible refactor to help this in the new hook fetchDomains
.
|
||
const [assets, setAssets] = useState({ | ||
assetRows: [] as ManageAssetCurrency[], | ||
// TODO: REFACTOR getAccountBalances to a hook |
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.
I think it would be good to line up getAccountBalances
to move to a hook similar to useGetHistory
. This shared state made it tricky to ensure the correct loading/initial state across several views sharing it. Each view relies on unrelated views to "clean up" the state in order for the pages to work correctly.
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.
Yeah, good call - that'd be a much nicer improvement than having to manually rehydrate
import "./styles.scss"; | ||
|
||
export const defaultAccountBalances = { |
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.
Just getting rid of a little cruft here.
import { PrivateKeyRoute } from "popup/Router"; | ||
import { ROUTES } from "popup/constants/routes"; | ||
|
||
export const ManageAssets = () => { |
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.
Both views that need balances here now need to fetch them on render, this is because AssetVisibility
needs to not filter hidden assets, and ChooseAsset
needs to take the hidden assets into account.
response = await sendMessageToBackground({ | ||
type: SERVICE_TYPES.CHANGE_ASSET_VISIBILITY, | ||
assetVisibility: { | ||
issuer: assetIssuer, |
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.
We'll run into an issue here when a G address is the issuer for multiple assets.
Here's an example of an issuer on Mainnet who issues multiple assets under one address: GBX23RCWKV7DA23J2MA2OFMTRV3XZHHKOTHBQF6AKOEP7AGQUIZZXLMG
I think you might just want to use {assetCode}:{assetIssuer}
as your key here
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.
@
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.
@piyalbasu very good point thank you, will update to use the composite key.
Can an issuer have two assets that use the same ticker?
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.
done in 0512f6c
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.
Oh, that's a good question about multiple assets using the same ticket. Off the top of my head, I'm not 100% sure. We may need to test it out and see if the network lets us do it
/> | ||
<Toggle | ||
checked={isAssetVisible(hiddenAssets, issuer)} | ||
id="isVisible" |
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.
NIT: you'll potentially end up with multiple elements with the same id
. Not sure how much that actually matters here - but to be syntactically correct, you might wanna use something like isVisible-${code}:${issuer}
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.
ah yeah I didn't use the ID in this case but will update for completeness
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.
done in 0512f6c
color: var(--sds-clr-gray-09); | ||
|
||
svg { | ||
margin-right: 0.25rem; |
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.
NIT: would you mind using pxToRem? It'd be nice to start removing rem
altogether from the codebase over time
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.
done in 0512f6c
@@ -175,7 +165,6 @@ export const Account = () => { | |||
return ( | |||
<> | |||
<AccountHeader | |||
// accountDropDownRef={accountDropDownRef} |
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.
🎉
expect(childInput).toBeChecked(); | ||
fireEvent.change(childInput, { target: { checked: false } }); | ||
expect(childInput).not.toBeChecked(); | ||
}); |
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.
It might be nice to have an e2e test for this. It would cover the UI stuff plus make sure the background is properly saving hidden assets
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.
yeah good call it would make sense to navigate to the account view and test for the hidden asset being missing from the list also, let me see what I can add here.
@@ -23,3 +23,4 @@ export const IS_HASH_SIGNING_ENABLED_ID = "isHashSigningEnabled"; | |||
export const IS_NON_SSL_ENABLED_ID = "isNonSSLEnabled"; | |||
export const IS_BLOCKAID_ANNOUNCED_ID = "isBlockaidAnnounced"; | |||
export const IS_HIDE_DUST_ENABLED_ID = "isHideDustEnabled"; | |||
export const HIDDEN_ASSETS = "hiddenAsset"; |
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.
export const HIDDEN_ASSETS = "hiddenAsset"; | |
export const HIDDEN_ASSETS = "hiddenAssets"; |
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.
😄 thanks
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.
done in 365d79b
&--short { | ||
flex-grow: 1; | ||
} |
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.
does it make sense to have this one since it's not adding any actual change?
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.
oh good call this came from a similar view but its not needed here. Removing.
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.
done in 365d79b
&__content { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.5rem; |
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.
should we use pxToRem() in all values from this file?
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.
Yup! Adding...
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.
done in 365d79b
Closes #1620
Design: https://www.figma.com/design/C3G0a4Gd6RQyplRBppGDsL/Freighter-(SDS-v3)?node-id=2932-3383&t=KhdFFpbyyxRgbwuo-1
What
Adds a "Toggle Assets" page, where users can select assets to hide from their views.
Why
Users may no longer want to see assets where they have "dust" and no longer care or for whatever other reason they may want to remove the asset from view while still keeping it in their assets list.
Notable Changes:
Adds new internal actions
GET_HIDDEN_ASSETS
&CHANGE_ASSET_VISIBILITY
which operate on a new storage keyHIDDEN_ASSETS
.HIDDEN_ASSETS
is a map of<issuer key, "hidden" | "visible">
.Adds new "toggle assets" page and navigation action from the "Manage Assets" page.
Changes
getAccountBalances
to accept a new arg,showHidden
. This can be used to filter out assets according to their state inHIDDEN_ASSETS
.Refactors
ChooseAsset
to fetch it's own balances, it now needs to account for hidden assets.Extracts a new hook,
useFetchDomains
to be used in bothChooseAsset
andAssetVisibility
.Adds new test for toggling an asset's visibility.