open-dollar / od-app

https://app.dev.opendollar.com
6 stars 4 forks source link

Issue #595: Viewing vault as another user #601

Closed jahabeebs closed 3 months ago

jahabeebs commented 3 months ago

closes #595

Description

The issue occurs when a user views the app as another wallet -> automatically is navigated to /vaults -> user navigates to a vault -> user connects their wallet

I tried to make changes in the useEffect in VaultDetails to prevent an infinite loop, but it seems like when a user connects their wallet the app's data becomes polluted (maybe a mismatch of liquidation/safe data for the safe the user is viewing vs. what was fetched as another user?) and it triggers an infinite loop. Some other things I've tried are memoizing the data in VaultDetails, adding debouncing to see if it's a timing issue (it's not), removing the safeActions.setSingleSafe(null) cleanup function (which helps trigger the infinite loop) but removing this causes the caching issue we had before (where a user with 1+ vaults will only ever see the data for the first vault they click)

Screenshots

In this example I'm connected as another wallet -> I click into a vault -> I connect my wallet -> the app pushes me back to /vaults where the data is refreshed and I can see my own vault

https://github.com/open-dollar/od-app/assets/47253537/9699e091-f406-4178-83a8-f62bc157eec7

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
od-app ✅ Ready (Inspect) Visit Preview Jun 27, 2024 10:16pm
od-app-hai ✅ Ready (Inspect) Visit Preview Jun 27, 2024 10:16pm
od-app-testnet ✅ Ready (Inspect) Visit Preview Jun 27, 2024 10:16pm
jahabeebs commented 3 months ago

@pi0neerpat You were right about this causing a bug where you can't see others' vaults--I'm going to have to try the alternative solution you suggested of storing another user's safes in a separate state variable and seeing if that will prevent issues

pi0neerpat commented 3 months ago

Vault explore page replaces the need for the "view as another wallet" feature