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

2084 Bug | Roles Data doesn't refresh #2188

Merged
merged 19 commits into from
Aug 8, 2024
Merged

Conversation

DarksightKellar
Copy link
Contributor

This PR fixes an elusive bug: switching safes was not reloading the new safe's roles. IOW, the previous safe's roles would be visible in the new safe's roles page.

Ideally I should've branched off develop and used that as this PR's base, but, alas, I branched off roles-0.2.0/streams instead. Means this fix will make it to develop only when streams does. Not the most terrible thing to have happened in the world, since this was never an urgent bug in the first place.

Also snuck in a tiny update I made to the "today" indicator on the DecentDatePicker component

Copy link

netlify bot commented Jul 30, 2024

Deploy Preview for decent-interface-dev ready!

Name Link
🔨 Latest commit 3b89526
🔍 Latest deploy log https://app.netlify.com/sites/decent-interface-dev/deploys/66b4d9ff3ffc710008d33fe2
😎 Deploy Preview https://deploy-preview-2188.app.dev.decentdao.org
📱 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
Member

@adamgall adamgall left a comment

Choose a reason for hiding this comment

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

I'd like to see an explicit reset function, rather than just calling setHatsTreeId(null)

Copy link
Member

@adamgall adamgall left a comment

Choose a reason for hiding this comment

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

It's possible to switch Safes without invoking the HomePage component at all (via the search bar). Does this work in that case?

There is another place in the app where resetSafeState() is called. Should this Zustand reset go there, too?

@DarksightKellar
Copy link
Contributor Author

DarksightKellar commented Jul 30, 2024

It's possible to switch Safes without invoking the HomePage component at all (via the search bar). Does this work in that case?

Tested this, the roles don't persist into the next safe

There is another place in the app where resetSafeState() is called. Should this Zustand reset go there, too?

I don't think so. Regardless, all paths to switch safes that I tested didn't persist a previous safe's roles. Also this bug was hard to reproduce in the first place, so while I did test alternate paths, most testing was focused on the reliable edge case where roles were not getting cleared out
@adamgall

@adamgall
Copy link
Member

@DarksightKellar what is the mechanism that allows the Zustand stores to reset themselves when a Safe is changed through the search bar, if we're not explicitly doing that?

@DarksightKellar
Copy link
Contributor Author

@adamgall I think this useEffect in useKeyValuePairs is the answer:
Screenshot 2024-07-31 at 12 52 53

it's got a daoAddress dependency (and chain id)

getHatsTreeId itself may return null or undefined, so if the context safe has no such events, the "reset" happens, here (which is something I believe you anticipated when building this part out, hence this code):
Screenshot 2024-07-31 at 12 55 05

@DarksightKellar DarksightKellar requested review from adamgall, a team and Da-Colon July 31, 2024 11:58
@adamgall
Copy link
Member

I don't like relying on this side effect to "clear out" the state. Would prefer that happens more explicitly.

@DarksightKellar
Copy link
Contributor Author

I don't like relying on this side effect to "clear out" the state. Would prefer that happens more explicitly.

@adamgall Hmm I think you've gotten too hung up on the "clear out state" semantic. Hear me out:

useKeyValuePairs is the way to load up a safe's hat tree, regardless. We don't know before checking it if a safe has a tree or not, so getHatsTreeId(safeEvents... could return null or undefined if the context safe doesn't in fact have a (declared) tree. In that case setHatsTreeId will (and should) be called with null or undefined. This is a feature and not a happy accident -- It's not a "clearing out state" side effect, it's a "setting the tree for this safe we have just switched to" intentional effect.

I don't see any need to, somewhere else, do:

  • listen for safe changes
  • try to get the new safe's tree
  • if safe has got no tree, specifically reset the tree store
  • OR specifically set the tree store if the safe happens to have one.

Actually a better argument would be to rename useKeyValuePairs to something along the lines of useLoadSafeHatsTree, because that is all it is doing. It just so happens to be using the KeyValuePairs contract internally.

@adamgall adamgall linked an issue Aug 2, 2024 that may be closed by this pull request
@tomstuart123
Copy link

@DarksightKellar - to replicate is it as simple as jumping between safe's role pages quickly?

Copy link
Member

@adamgall adamgall left a comment

Choose a reason for hiding this comment

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

Approving, but one suggestion

const todayDotLeftMargin = useBreakpointValue({ base: '5vw', md: '1.35rem' });
const todayDotLeftMargin = useBreakpointValue({ base: '4.5vw', md: '1.15rem' });

const isTodaySelected = () => {
Copy link
Member

Choose a reason for hiding this comment

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

This returns boolean | undefined. Can it be cleaned up to only return a boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah good call

@tomstuart123
Copy link

tomstuart123 commented Aug 6, 2024

@adamgall / @DarksightKellar - roles jumping between safes issue still appears for me
Video of issue risen here - https://decentdao.slack.com/archives/C06QZTUTKRC/p1722952950606279?thread_ts=1722949970.035939&cid=C06QZTUTKRC

@adamgall adamgall merged commit 037117e into roles-0.2.0/streams Aug 8, 2024
7 checks passed
@adamgall adamgall deleted the 2084-reload-roles branch August 8, 2024 15:37
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.

[roles-0.1.0] Bug | Roles Data doesn't refresh
4 participants