-
Notifications
You must be signed in to change notification settings - Fork 339
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
591/base/profile logic #615
Conversation
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.
The following should be merged together as they come hand in hand. Right now i've tested this on the likecoin chain and what i saw was, you didn't display the profile if it wasn't connected to said chain (correct) but then router corrected the casing (wrong)
useEffect(() => {
if (state.desmosProfile) {
const dtagInput = router.query.dtag as string;
if ((`@${state.desmosProfile.dtag}` !== dtagInput) && (`@${state.desmosProfile.dtag.toUpperCase()}` === dtagInput.toUpperCase())) {
router.push({ pathname: `/@${state.desmosProfile.dtag}` }, `/@${state.desmosProfile.dtag}`, { shallow: true });
}
}
}, [state.desmosProfile]);
useEffect(() => {
if (state.desmosProfile) {
const dtagConnections = state.desmosProfile.connections;
const dtagConnectionsNetwork = dtagConnections.map((x) => { return x.identifier; });
const chainPrefix = chainConfig.prefix.account;
let containNetwork = false;
dtagConnectionsNetwork.map((x) => {
if (x.startsWith(chainPrefix)) { containNetwork = true; }
return containNetwork;
});
if (!containNetwork) {
handleSetState({
exists: false,
});
}
}
}, [state.desmosProfile]);
We want to check that we can display this profile first and only then, should we think about the casing.
I would suggest making cleaning it up so that i can look something like this (not perfect but you get the point):
useEffect(() => {
if (state.desmosProfile) {
const showProfile = shouldShowProfile();
if (showProfile) {
// handle route casing update if needed
shouldUpdateRoute()
} else {
// do not show profile
handleSetState({
exists: false,
});
}
}
}, [state.desmosProfile]);
I recommend using some
instead of map
for what you are trying to accomplish
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
let containNetwork = false;
dtagConnectionsNetwork.map((x) => {
if (x.startsWith(chainPrefix)) { containNetwork = true; }
return containNetwork;
});
* 602/optimize tx list aggregation (forbole#603) * add: versioning ui (forbole#609) * 604/themes (forbole#610) * update graphql to case insensitive (forbole#606) * add: avatarnamelist (forbole#620) * 591/base/profile logic (forbole#615) * Checkout before tag (forbole#630) * update: optimize initial load (forbole#641) * fix: home page latest blocks (forbole#646) * 645/update config (forbole#647) * fixed: dependencies (forbole#665) * fix: gql with utc (forbole#669) * add: sanitzation (forbole#671) * fix: pagination (forbole#672) Co-authored-by: Ryuash <[email protected]> Co-authored-by: yayay927 <[email protected]>
closes #591
Description
Checklist
CHANGELOG.md
file.Files changed
in the Github PR explorer.