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

config: only save non default values #1023

Merged
merged 1 commit into from
Mar 15, 2023

Conversation

ReenigneArcher
Copy link
Member

@ReenigneArcher ReenigneArcher commented Mar 10, 2023

Description

Only save non default config values.

Also fixes a potential issue where new FPS values were quoted, as discovered when reviewing #1002.

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

@@ -1050,33 +1055,57 @@ <h1 class="my-4">Configuration</h1>
this.resolutions.join("," + nl + " ") +
nl +
"]";
this.config.fps = JSON.stringify(this.fps);
// remove quotes from values in fps
this.config.fps = JSON.stringify(this.fps).replace(/"/g, "");
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes a possible bug where new FPS values were added surrounded by quotes, whereas the default values where without quotes.

},
save() {
this.saved = this.restarted = false;
this.serialize();

// create a temp copy of this.config to use for the post request
let config = JSON.parse(JSON.stringify(this.config))
Copy link
Member Author

Choose a reason for hiding this comment

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

A temp copy of the config is created, because if we delete this.config[key], the values are removed from the UI once you save them.

}).then((r) => {
if (r.status === 200) this.saved = true;
});
},
apply() {
this.saved = this.restarted = false;
this.serialize();
fetch("/api/config", {
Copy link
Member Author

@ReenigneArcher ReenigneArcher Mar 10, 2023

Choose a reason for hiding this comment

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

This was removed, since the user must already click "Save" for the "Apply" button to appear... but we will save again anyway just to be safe (but without repeating code).

@ReenigneArcher ReenigneArcher force-pushed the config-only-save-non-default-values branch from 6debd1a to e18358d Compare March 15, 2023 20:31
@ReenigneArcher ReenigneArcher merged commit afc6966 into nightly Mar 15, 2023
@ReenigneArcher ReenigneArcher deleted the config-only-save-non-default-values branch March 15, 2023 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant