Skip to content
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

MyLand refresh/navigation fix #333

Merged
merged 21 commits into from
Apr 24, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions decentraland/screens/MyAssetsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,33 @@ export class MyAssetsScreen extends React.Component {
const shouldUpdate = !listsAreEqual(assetsFromBlockchain, boughtAssets);
if (shouldUpdate) {
// TODO: Add some UI indication that something unexpected happened
logWarn(
`Account's assets from blockchain aren't the same as the ones stored on the app.`
);
this._logAssetsInconsistency(assetsFromBlockchain, boughtAssets);
removeFromMyAssetsList(boughtAssets);
appendToMyAssetsList(assetsFromBlockchain);
pcowgill marked this conversation as resolved.
Show resolved Hide resolved
}
}
};

_logAssetsInconsistency = (fromBlockchain, fromState) => {
const fromBlockchainIds = fromBlockchain.map(asset => asset.id);
const fromStateIds = fromState.map(asset => asset.id);

const addedIds = fromBlockchainIds.filter(id => !fromStateIds.includes(id));
const removedIds = fromStateIds.filter(
id => !fromBlockchainIds.includes(id)
);

logWarn(
`Account's assets from blockchain aren't the same as the ones stored on the app.`
);

if (addedIds.length > 0)
logWarn(`Some assets added to MyLandScreen. IDs: [${addedIds}]`);
marcelomorgado marked this conversation as resolved.
Show resolved Hide resolved

if (removedIds.length > 0)
logWarn(`Some assets removed from MyLandScreen. IDs: [${removedIds}]`);
};

_getAssetsFromBlockchain = async address => {
const listOfPromises = await this._getAssetsOf(address);
const fromBlockchain = await Promise.all([...listOfPromises]);
Expand Down