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

Settings Changes Not Reflected in Other Windows #1352

Closed
dsanders11 opened this issue May 10, 2023 · 0 comments · Fixed by #1376
Closed

Settings Changes Not Reflected in Other Windows #1352

dsanders11 opened this issue May 10, 2023 · 0 comments · Fixed by #1376
Labels
area:settings 🪲 bug Something isn't working good first issue Good for newcomers

Comments

@dsanders11
Copy link
Member

If you have multiple windows open, updating a setting in one window is not reflected in the other windows. Came across this when I updated my GitHub PAT in one window and it wasn't used in the others.

Most visible repro case would be to change the theme in one window and observe that other windows remain on the previous theme.

Suggested plan of attack based off of some brief consideration (alternatives welcome):

  1. Add an enum SettingKey to src/interfaces.ts which lists all keys used to store settings in localStorage
  2. Update all usages of localStorage.getItem/localStorage.setItem to use those enum values
  3. In AppState.save, send an IPC event to main process, e.g. window.ElectronFiddle.settingsChanged()
  4. In main process, listen for that IPC event, then broadcast a "refresh-settings" event to all windows except the sender
  5. In AppState constructor, listen for that event (window.ElectronFiddle.addEventListener('refresh-settings', ...)) and loop through the enum keys, with a switch statement for key values and retrieve the latest value from localStorage and update the state accordingly for that setting

That should ensure exhaustiveness checking for the persisted settings to ensure we don't miss any during future changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:settings 🪲 bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant