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

Desktop: Fixes #10382: Fix default values for plugin settings stored in settings.json not applied #10383

Conversation

personalizedrefrigerator
Copy link
Collaborator

Summary

This pull request fixes an issue where plugin settings saved using SettingStorageType.File did not use the setting's specified default value.

Fixes #10382.

Notes

This pull request makes Setting.loadOne return null when a file setting has no saved value. This is consistent with the behavior for database settings. Previously, loadOne would return an object for a file setting, even when that setting had no saved value. This would cause the setting to be loaded into the cache (without using its default value):

const valueRow = await this.loadOne(key);
if (valueRow) {
// Remove any duplicate copies of the setting -- if multiple items in cache_
// have the same key, we may encounter unique key errors while saving to the
// database.
this.cache_ = this.cache_.filter(setting => setting.key !== key);
this.cache_.push({
key: key,
value: this.formatValue(key, valueRow.value),

Testing plan

This pull request has an automated test. It has also been tested manually by:

  1. Installing the CodeMirror 6 settings plugin
    • Remove settings.json if the plugin was previously installed.
  2. Restarting Joplin
  3. Verifying that the value for the "line numbers" setting is true.

@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Fixes #10382: Fix default values for settings.json plugin settings not applied Desktop: Fixes #10382: Fix default values for plugin settings stored in settings.json not applied Apr 28, 2024
@laurent22 laurent22 merged commit 569b567 into laurent22:dev May 2, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugins: Default values not applied for SettingStorageType.File settings
2 participants