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

591/base/profile logic #615

Merged
merged 26 commits into from
Jan 6, 2022
Merged

591/base/profile logic #615

merged 26 commits into from
Jan 6, 2022

Conversation

yayay927
Copy link
Contributor

@yayay927 yayay927 commented Dec 23, 2021

closes #591

Description

Checklist

  • Ran Linting
  • Targeted PR against correct branch.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit tests.
  • Added an entry to the CHANGELOG.md file.
  • Re-reviewed Files changed in the Github PR explorer.

@yayay927 yayay927 marked this pull request as ready for review December 24, 2021 03:23
@yayay927 yayay927 requested a review from ryuash December 24, 2021 03:23
src/screens/profile_details/hooks.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ryuash ryuash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

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;
      });

ryuash
ryuash previously approved these changes Dec 28, 2021
src/components/nav/components/mobile/hooks.test.ts Outdated Show resolved Hide resolved
src/components/nav/components/mobile/hooks.test.ts Outdated Show resolved Hide resolved
src/hooks/use_desmos_profile.ts Show resolved Hide resolved
@ryuash ryuash merged commit c02246c into base Jan 6, 2022
@ryuash ryuash deleted the 591/base/profile-logic branch January 6, 2022 03:22
rach-id added a commit to celestiaorg/big-dipper-2.0-cosmos that referenced this pull request Jan 19, 2022
* 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 <42913823+ryuash@users.noreply.github.com>
Co-authored-by: yayay927 <32444273+yayay927@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix / Base: profiles logic
2 participants