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

Fix ENS and UNS names not visible in UI #879

Merged
merged 5 commits into from
Dec 14, 2023
Merged

Fix ENS and UNS names not visible in UI #879

merged 5 commits into from
Dec 14, 2023

Conversation

xpaczka
Copy link
Contributor

@xpaczka xpaczka commented Dec 12, 2023

Issues connected

Resolves #823

What has been done

  • Fixed ENS and UNS names not updated automatically (without reload)
  • Added useCachedWalletName hook

Testing

  • Clear localStorage
  • Connect wallet
  • After a short interval, account name is automatically updated
  • Reload the page, the name is still visible

@xpaczka xpaczka self-assigned this Dec 12, 2023
Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for taho-development ready!

Name Link
🔨 Latest commit d28514c
🔍 Latest deploy log https://app.netlify.com/sites/taho-development/deploys/65797f5a8c74ca0008196e0c
😎 Deploy Preview https://deploy-preview-879--taho-development.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@jagodarybacka jagodarybacka left a comment

Choose a reason for hiding this comment

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

I feel like we were missing some connections between utils <> cache <> redux but to me it seems like they are still not quite there yet. What about utilizing some redux features (async thunks? maybe names need to have their own service?) to trigger the state changes correctly without a need to use events on window object?

Comment on lines 293 to 294
if (ens) setAccountName(ens.name)
if (uns) setAccountName(uns.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

ENS names should override UNS names if user has both (same as we have it in the wallet)

Comment on lines +297 to +299
window.addEventListener("storage", handleCachedNamesUpdate)

return () => window.removeEventListener("storage", handleCachedNamesUpdate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like we are doing something weird trying to communicate between a util and a hook via events on the window. I feel like we are trying to achieve the same thing here as we would have if we just triggered the change on the redux slice?

@@ -10,7 +10,11 @@ import { getRealmColor } from "shared/constants"
import Avatar from "shared/components/Media/Avatar"
import AccountDropdown from "./AccountDropdown"

export default function AccountInfo() {
type AccountInfoProps = {
accountName: string | null
Copy link
Contributor

Choose a reason for hiding this comment

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

why can't we just rely on the const name = useDappSelector(selectWalletName)? having two sources of truth here smells like a bad idea.

@xpaczka xpaczka marked this pull request as draft December 13, 2023 08:17
@xpaczka xpaczka marked this pull request as ready for review December 13, 2023 10:01
Copy link
Contributor

@jagodarybacka jagodarybacka left a comment

Choose a reason for hiding this comment

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

I don't love this approach but let's just make it work 🚀

@jagodarybacka jagodarybacka merged commit 80e931b into main Dec 14, 2023
4 checks passed
@jagodarybacka jagodarybacka deleted the ens-names branch December 14, 2023 12:57
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.

ENS names are lagging to become visible
2 participants