Skip to content

Commit

Permalink
Refactor: Extracted logic into a private method
Browse files Browse the repository at this point in the history
  • Loading branch information
revolter committed Feb 28, 2024
1 parent e9a1f25 commit b07c7b6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/settings/RecipesSettingsTab.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, Plugin, PluginSettingTab } from 'obsidian';
import { App, Plugin, PluginSettingTab, Setting } from 'obsidian';
import 'src/html/HTMLElementExtensions';
import { HanayamaHuzzlesRecipe } from 'src/recipes/hanayama_huzzles/HanayamaHuzzlesRecipe';
import { HanayamaHuzzlesRecipeExtraSettingsAdder } from 'src/recipes/hanayama_huzzles/settings/HanayamaHuzzlesRecipeExtraSettingsAdder';
Expand Down Expand Up @@ -50,9 +50,7 @@ export class RecipesSettingsTab extends PluginSettingTab {
async value => {
settings.isActive = value;

extraSettings.forEach(setting => {
setting.setDisabled(!value);
});
this.#setSettingsEnabled(extraSettings, value);

await this.settingsManager.saveSettings();
}
Expand All @@ -72,4 +70,10 @@ export class RecipesSettingsTab extends PluginSettingTab {
}
);
}

#setSettingsEnabled(settings: Setting[], enabled: boolean) {
settings.forEach(setting => {
setting.setDisabled(!enabled);
});
}
}

0 comments on commit b07c7b6

Please sign in to comment.