-
Notifications
You must be signed in to change notification settings - Fork 909
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
Tweak portfolio UI and add option to show hidden NFTs #19990
Conversation
@@ -384,7 +445,7 @@ private void recordP3AView() { | |||
if (activity instanceof BraveWalletActivity) { | |||
BraveWalletActivity walletActivity = (BraveWalletActivity) activity; | |||
BraveWalletP3a walletP3A = walletActivity.getBraveWalletP3A(); | |||
if (walletP3A != null) { | |||
if (walletP3A != null && mNftDataModels != null) { |
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.
Improved check as the wallet was crashing here.
TokenUtils.getUserOrAllTokensFiltered(braveWalletService, blockchainRegistry, | ||
networkInfo, networkInfo.coin, TokenUtils.TokenType.NFTS, true, userAssets -> { | ||
mUserAssets.addAll(Arrays.asList(userAssets)); | ||
|
||
if (userAssetsCount.incrementAndGet() == totalNetworks) { | ||
mUserAssets.sort(Comparator.comparing( | ||
token -> mAssertSortPriorityPerCoinIndex.get(token.chainId))); | ||
AtomicInteger allAssets = new AtomicInteger(); | ||
final List<BlockchainToken> assets = new ArrayList<>(); | ||
for (NetworkInfo selectedNetwork : mSelectedNetworks) { | ||
TokenUtils.getUserOrAllTokensFiltered(braveWalletService, | ||
blockchainRegistry, selectedNetwork, selectedNetwork.coin, | ||
TokenUtils.TokenType.NFTS, false, tokens -> { |
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.
TokenUtils.getUserOrAllTokensFiltered
with true
and false
is internally calling braveWalletService.getUserAssets
for each networks twice. The result of braveWalletService.getUserAssets
can be persisted during the first call and can be reused with with getAllTokensFiltered
to reduce latency.
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.
👍
LiveDataUtil.observeOnce(getNetworkModel().mCryptoNetworks, | ||
networkList |
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.
PortfolioModel
has the mAllNetworkInfos
. Add a getter and reuse it than LiveDataUtil.observeOnce(getNetworkModel().mCryptoNetworks,
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, right! Nice catch, thank you!
mPortfolioModel.fetchNfts( | ||
mSelectedNetworkList, (BraveWalletBaseActivity) activity, (portfolioHelper) -> { | ||
if (!AndroidUtils.canUpdateFragmentUi(this)) return; | ||
mPortfolioHelper = portfolioHelper; | ||
List<BlockchainToken> nfts = mPortfolioHelper.getUserAssets(); | ||
LiveDataUtil.observeOnce(getNetworkModel().mCryptoNetworks, networkInfos -> { | ||
mPortfolioModel.prepareNftListMetaData( | ||
nfts, networkInfos, mPortfolioHelper); | ||
}); | ||
List<BlockchainToken> hiddenNfts = mPortfolioHelper.getHiddenAssets(); | ||
LiveDataUtil.observeOnce(getNetworkModel().mCryptoNetworks, | ||
networkList | ||
-> mPortfolioModel.prepareNftListMetaData( | ||
nfts, hiddenNfts, networkList, mPortfolioHelper)); |
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: We always gonna be needing NFT meta data (can add a new method if not) so fetchNfts
can internally call prepareNftListMetaData
directly for further processing to remove the back and forth data passing/calls.
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.
strings
++
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.
LGTM, added some comments to improve performance. (can be addressed later if suitable).
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.
++
Resolves brave/brave-browser#32545
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: