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 debug page contracts view #975

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Conversation

rin-st
Copy link
Member

@rin-st rin-st commented Oct 28, 2024

Description

Fixes #939

One of the possible (and simple) solutions is to use sessionStorage instead of localStorage. As I understand it doesn't change anything except one case:
User worked with debug page where he chose some non-first contract. User closes browser tab with his debug page and open debug page in another browser tab. With localStorage, last chosen contract will be selected. With sessionStorage first contract will be selected. I believe it's not a problem at all

Additionally, using sessionStorage adds possibility to view different contracts of debug page in different browser tabs


What I also tried to do:

  • use simple hash function depending on contractNames
const [selectedContract, setSelectedContract] = useLocalStorage<ContractName>(
    ${selectedContractStorageKey}-${hash},
    contractNames[0],
    { initializeWithValue: false },
  );

it works great, but adds new entry to localstorage for every hash

  • use one localStorage for selectedContract and one for hash. But in this case I needed to use useEffects to handle logic and again it didn't work for multiple tabs, same as bug: Debug tabs behavior #939

@carletex
Copy link
Member

With sessionStorage first contract will be selected. I believe it's not a problem at all

Agree.

The main reason we have this functionality is to avoid "losing the contract focus" if you refresh the page. And session storage does the trick too

Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

With localStorage, last chosen contract will be selected. With sessionStorage first contract will be selected. I believe it's not a problem at all

Yess event I think its not a big deal at all!

Just tested out nicely and #939 is fixed! Thanks @rin-st!

@technophile-04 technophile-04 merged commit 4fad12a into main Oct 29, 2024
1 check passed
@technophile-04 technophile-04 deleted the fix-debug-tab-behavior branch October 29, 2024 04:42
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.

bug: Debug tabs behavior
3 participants