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

[WIP] Within-app profile update post editing #1078

Closed
wants to merge 22 commits into from

Conversation

dysbulic
Copy link
Member

@dysbulic dysbulic commented Jan 25, 2022

Overview

What features/fixes does this PR include?

This PR adds the Jotai state management library to propagate changes made by editing a player's profile to the display version.

The code in #943 writes to the Ceramic Network from the user's browser and notifies Hasura to renew its cache for that user. There is a time delay between when the user saves their changes and when an updated version of the profile page is available. This is exacerbated by caching by Next.js. This PR directly updates the profile page within the app so the user sees their inputted information.

There are also a couple of consistency changes, most notable switching PlayerFragmentFragment to Player throughout. Also the removal of the gql fake-tag in favor of the /* GraphQL */ identifier.

useUser now simply returns a Player object rather than a user object with a player attribute. The name of the returned object is still user. Also, rather than using the same query for the player avatar in the top menu with a dozen @skip if $forLoginDisplays, there is now a separate useLoginBasics query that only returns the details needed for that avatar.

Please provide the GitHub issue number

Closes #887 though "optimistic updates" is something of a misnomer because the editing flow will successfully complete the write to Ceramic and Hasura cache invalidation before it will update the values in Jotai.

Also, divides the GitHub deployment Action into separate jobs to address #1062 & moves the seeding step before the frontend generation step for #1083.

Follow up Improvement Ideas

There are a couple places we are prop drilling which could potentially be cleaned up using Jotai.

On a side note, there's also a Hasura migration to make skill / player combinations unique. Somehow the test deployment had double entries for all the players' skills for a bit & this should be prevented at the database level. It's unrelated, but the Hasura schema in this branch is ahead of develop, so I just put it here.

Implementation

The PR adds a useProfileField hook that provides access to the profile data that can be overwritten with local state.

It also adds a useSaveCeramicProfile that takes hashes of values and images, and sets the appropriate profile stream properties. (Values are stored in two separate streams, a basic one defined by 3Box and an extended one of my creation.) That hook also handles setting the local state values for the UI.

@dysbulic dysbulic added WIP frontend Front end related issues / features labels Jan 25, 2022
@dysbulic dysbulic self-assigned this Jan 25, 2022
@vercel
Copy link

vercel bot commented Jan 25, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/metafam/the-game/7QiQE47pMGTnRWCbkk7F5rBc6sAm
✅ Preview: https://the-game-git-feat-jotai-profile-editing-metafam.vercel.app

@dysbulic dysbulic marked this pull request as ready for review January 25, 2022 16:23
@github-actions
Copy link

Successfully deployed a preview of this pull request:

@github-actions
Copy link

github-actions bot commented Feb 1, 2022

Successfully deployed a preview of this pull request:

@github-actions
Copy link

github-actions bot commented Feb 1, 2022

Successfully deployed a preview of this pull request:

@github-actions
Copy link

github-actions bot commented Feb 1, 2022

Successfully deployed a preview of this pull request:

@dysbulic dysbulic changed the base branch from develop to feat/eliminate-user.player February 8, 2022 06:48
dysbulic added a commit that referenced this pull request Feb 8, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
dysbulic added a commit that referenced this pull request Feb 8, 2022
dysbulic added a commit that referenced this pull request Feb 8, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
*
Base automatically changed from feat/eliminate-user.player to develop February 8, 2022 18:13
dysbulic added a commit that referenced this pull request Feb 8, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
*
dysbulic added a commit that referenced this pull request Feb 8, 2022
tenfinney added a commit that referenced this pull request Feb 8, 2022
dysbulic pushed a commit that referenced this pull request Feb 14, 2022
@dysbulic
Copy link
Member Author

This PR has been broken into smaller requests for easier reviewing: #1103, #1115, #1116, #1124, & #1127.

@dysbulic dysbulic closed this Feb 15, 2022
@dysbulic dysbulic deleted the feat/jotai-profile-editing branch February 15, 2022 01:00
dysbulic pushed a commit that referenced this pull request Feb 16, 2022
dan13ram pushed a commit that referenced this pull request Feb 16, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
*
dan13ram pushed a commit that referenced this pull request Feb 16, 2022
dysbulic pushed a commit that referenced this pull request Feb 20, 2022
tenfinney added a commit that referenced this pull request Feb 28, 2022
dysbulic added a commit that referenced this pull request Feb 28, 2022
* incorporating configuration panes from #1078

* standardizing player hero subcomponents & removing `owner` var from `useProfileField` 🚪

* switching box type, ambiguating overly-specific names, & massaging heights 📱

* reordering profile details sections, updating deployment environment, & conditionally wrapping the hero elements 🎬

* fixing render of color disposition selector 🕍

* self code review changes: removed some `;`s 🎋

* getting yarn typecheck && yarn lint to pass post rebase 🏇🏾

* handling "missing <div> in <button>" error with mounted check & setting HTTP return codes for OpenSea API endpoint 🕺

* `ProfileWizard` extends `Wizard`, roles display better on mobile, & pronouns use `ProfileWizardPane` 🍊

* properly encapsulating ETH address regex 🚲

* adding some tasks 🏥

* fixed skills layou

* handling default values? ❔

* corrections for revision comments from @dan13ram (UI bugs to follow) 🌋

* cleaning up memberships & explorer type 🧫

* refactoring player roles configuration and display to use `WizardPane` 🔮

* bunches of mobile fixes & repairing the display of deserialized skills 📟

* removing redirect in static props & formatting memberships display for responsiveness 🪆

* improving comprehensability of `/me` & more mobile tweaking 🍦

* various spacing fixes & a “try again” button for connecting 🫕

* maybe fixed issue with saving images for fields with default values 🇩🇿

* switched roles selection to a bounded `SimpleGrid` to fix sizing weirdness 🧰

* fix: removed verify on brightId button

* fix: clean up username page

* formatting & fixing skills issues 🥩

* reformatting NFT display 🚂

* adding `/join` 🚉

* style: peth's suggestions

* added mainnet required message

* style: slight tweak of megamenu item positions

* chore(release): 0.2.0

Co-authored-by: tenfinney <scott@1box.onmicrosoft.com>
Co-authored-by: dan13ram <dan13ram@gmail.com>
Co-authored-by: vidvidvid <weetopol@gmail.com>
tenfinney pushed a commit that referenced this pull request Mar 1, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
tenfinney pushed a commit that referenced this pull request Mar 1, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
*
tenfinney pushed a commit that referenced this pull request Mar 1, 2022
tenfinney added a commit that referenced this pull request Mar 1, 2022
* incorporating configuration panes from #1078

* standardizing player hero subcomponents & removing `owner` var from `useProfileField` 🚪

* switching box type, ambiguating overly-specific names, & massaging heights 📱

* reordering profile details sections, updating deployment environment, & conditionally wrapping the hero elements 🎬

* fixing render of color disposition selector 🕍

* self code review changes: removed some `;`s 🎋

* getting yarn typecheck && yarn lint to pass post rebase 🏇🏾

* handling "missing <div> in <button>" error with mounted check & setting HTTP return codes for OpenSea API endpoint 🕺

* `ProfileWizard` extends `Wizard`, roles display better on mobile, & pronouns use `ProfileWizardPane` 🍊

* properly encapsulating ETH address regex 🚲

* adding some tasks 🏥

* fixed skills layou

* handling default values? ❔

* corrections for revision comments from @dan13ram (UI bugs to follow) 🌋

* cleaning up memberships & explorer type 🧫

* refactoring player roles configuration and display to use `WizardPane` 🔮

* bunches of mobile fixes & repairing the display of deserialized skills 📟

* removing redirect in static props & formatting memberships display for responsiveness 🪆

* improving comprehensability of `/me` & more mobile tweaking 🍦

* various spacing fixes & a “try again” button for connecting 🫕

* maybe fixed issue with saving images for fields with default values 🇩🇿

* switched roles selection to a bounded `SimpleGrid` to fix sizing weirdness 🧰

* fix: removed verify on brightId button

* fix: clean up username page

* formatting & fixing skills issues 🥩

* reformatting NFT display 🚂

* adding `/join` 🚉

* style: peth's suggestions

* added mainnet required message

* style: slight tweak of megamenu item positions

* chore(release): 0.2.0

Co-authored-by: tenfinney <scott@1box.onmicrosoft.com>
Co-authored-by: dan13ram <dan13ram@gmail.com>
Co-authored-by: vidvidvid <weetopol@gmail.com>
alalonde pushed a commit that referenced this pull request Mar 12, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
alalonde pushed a commit that referenced this pull request Mar 12, 2022
#1078 is at about 4,000 lines changed and includes both code implementing features and unrelated functional and stylistic changes. This set of changes is about ⅓ of the total and should be largely independent.

These changes include:

* have Dependabot ignore `patch` version changes
* switch the cache invalidation Hasura action to asynchronous
* add a uniqueness constraint on the combination of player and skill ids
* print a comprehensible error message in the db seeding script on network errors
* add a mutex on the account creation process & allow it to happen only once *(subsequent runs were failing b/c of the uniqueness constraint on the ETH address & returning `null` (closes #1098))
* adds some more profile editing related types
* renames `HighLow7dType` to `HighLowType`
* refactors the `ColorBar` component to include links to a color explanation
* replaces `fake-tag`'s `gql` string identifier with the dependency-free `/* GraphQL */`
* rename `lib/hooks/useUserXp.ts` to `useUserXP.ts`
* fixed some typings to remove `any`s
* bumped some library versions & fixed the version numbers of some others
*
alalonde pushed a commit that referenced this pull request Mar 12, 2022
alalonde pushed a commit that referenced this pull request Mar 12, 2022
* incorporating configuration panes from #1078

* standardizing player hero subcomponents & removing `owner` var from `useProfileField` 🚪

* switching box type, ambiguating overly-specific names, & massaging heights 📱

* reordering profile details sections, updating deployment environment, & conditionally wrapping the hero elements 🎬

* fixing render of color disposition selector 🕍

* self code review changes: removed some `;`s 🎋

* getting yarn typecheck && yarn lint to pass post rebase 🏇🏾

* handling "missing <div> in <button>" error with mounted check & setting HTTP return codes for OpenSea API endpoint 🕺

* `ProfileWizard` extends `Wizard`, roles display better on mobile, & pronouns use `ProfileWizardPane` 🍊

* properly encapsulating ETH address regex 🚲

* adding some tasks 🏥

* fixed skills layou

* handling default values? ❔

* corrections for revision comments from @dan13ram (UI bugs to follow) 🌋

* cleaning up memberships & explorer type 🧫

* refactoring player roles configuration and display to use `WizardPane` 🔮

* bunches of mobile fixes & repairing the display of deserialized skills 📟

* removing redirect in static props & formatting memberships display for responsiveness 🪆

* improving comprehensability of `/me` & more mobile tweaking 🍦

* various spacing fixes & a “try again” button for connecting 🫕

* maybe fixed issue with saving images for fields with default values 🇩🇿

* switched roles selection to a bounded `SimpleGrid` to fix sizing weirdness 🧰

* fix: removed verify on brightId button

* fix: clean up username page

* formatting & fixing skills issues 🥩

* reformatting NFT display 🚂

* adding `/join` 🚉

* style: peth's suggestions

* added mainnet required message

* style: slight tweak of megamenu item positions

* chore(release): 0.2.0

Co-authored-by: tenfinney <scott@1box.onmicrosoft.com>
Co-authored-by: dan13ram <dan13ram@gmail.com>
Co-authored-by: vidvidvid <weetopol@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Front end related issues / features WIP
Projects
Status: Done
2 participants