Skip to content

[General] Avoid unnecessary config writes #1988

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

Merged
merged 6 commits into from
Nov 23, 2022

Conversation

CommandMC
Copy link
Collaborator

@CommandMC CommandMC commented Nov 3, 2022

This PR checks settings values passed to setSetting and skips re-writing the config file if they haven't changed.

In the process of this, I've applied a similar treatment our useSetting hook got to getSetting and setSetting, which in turn involved setting a proper default value for currentConfig. Since that can be either AppSettings or GameSettings, depending on whether we're editing the global or game-specific settings, I've also made AppSettings extend GameSettings (so even if we only have a GameSettings object under the hood, we can still interact with it like it's a Partial<AppSettings> (since that's what it is))


Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@CommandMC CommandMC added pr:testing This PR is in testing, don't merge. pr:ready-for-review Feature-complete, ready for the grind! :P labels Nov 3, 2022
@CommandMC CommandMC requested a review from arielj November 3, 2022 23:18
@CommandMC CommandMC self-assigned this Nov 3, 2022
We can still compare any other falsy value (false, 0, '') just fine
I doubt anything other than '' will ever happen in practice though
@CommandMC CommandMC removed the pr:testing This PR is in testing, don't merge. label Nov 21, 2022
@CommandMC CommandMC requested review from a team, flavioislima, Nocccer, imLinguin and redromnon and removed request for a team November 21, 2022 13:56
@flavioislima flavioislima added the pr:ready-to-merge This PR is fully ready for merge. label Nov 23, 2022
Copy link
Member

@flavioislima flavioislima left a comment

Choose a reason for hiding this comment

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

Looks good.
Tested here and it is working fine.

@flavioislima flavioislima merged commit 8a46220 into beta Nov 23, 2022
@flavioislima flavioislima deleted the feat/no-unnecessary-config-writes branch November 23, 2022 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:ready-for-review Feature-complete, ready for the grind! :P pr:ready-to-merge This PR is fully ready for merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants