Skip to content

Settings are saved multiple times just by opening the settings screen #1463

Closed
@arielj

Description

@arielj

Describe the bug

When opening any settings screen (either Heroic's or a game), configuration is saved to disk multiple times.

Opening Heroic's settings the first time it writes the config 13 times. After that, changing to another sub-section (General, Wine, Other, etc), write the settings 3 more times. That's without doing any change.

Opening a game's settings the first time it writes the game's config 8 times for one game, 15 times for another, 16 times for another. After that, changing sub-sections writes the config 3 times for every section.

Going to another screen and back to settings starts with all the writes again.

Add logs

Nothing shows up on the logs, I put a console.log('writing config') in this useEffect in the settings index

  useEffect(() => {
    console.log('writing config')
    writeConfig([appName, settingsToSave])
  }, [GlobalSettings, GameSettings, appName])

This is just opening the settings for Magic The Gathering Arena (no changes at all)

image

Steps to reproduce

  1. Add the code shared above in the settings index.tsx line 329
  2. Open DevTools in Heroic and go to the console tab
  3. Enter the settings for heroic or any game, move around
  4. Multiple writing config lines are logged in the console

Expected behavior

Configuration should only be written when it changes, and only once. It should also NOT be written when opening settings or changing between sections.

Screenshots

No response

System Information

  • Heroic Version [e. g. 2.1.1]: current beta branch, but it's a long running issue since older versions

Additional information

I'm already debugging this trying to refactor it (I assigned this to me already), I'm creating the issue to keep track of it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions