Skip to content

Settings Changes Not Reflected in Other Windows #1352

@dsanders11

Description

@dsanders11

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions