Add setting to customize which macros display in properties#181
Add setting to customize which macros display in properties#181forketyfork wants to merge 1 commit intomainfrom
Conversation
Add toggles for each macro (calories, fats, protein, etc.) to enable/disable their display in daily note properties. Users who only track certain macros can now disable the others to reduce clutter from zeros in their daily notes. - Add EnabledFrontmatterFields interface for tracking enabled/disabled state - Update settings service with new setting and migration support for existing users - Add toggle controls alongside field name inputs in settings UI - Update applyNutrientTotalsToFrontmatter to respect enabled fields setting - Update README documentation
There was a problem hiding this comment.
Pull request overview
This PR adds user-configurable toggles to control which nutrition macros are displayed in daily note properties, reducing clutter for users who don't track all nutrients.
Changes:
- Introduced
EnabledFrontmatterFieldsinterface to track which macros should be displayed - Updated settings service with migration support for existing users (all fields enabled by default)
- Modified UI to include toggle controls alongside field name inputs for each macro
- Updated frontmatter logic to respect enabled/disabled field settings
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/SettingsService.ts | Adds EnabledFrontmatterFields interface, default values, clone function, and settings service methods |
| src/FrontmatterTotalsService.ts | Updates applyNutrientTotalsToFrontmatter to skip disabled fields when writing to frontmatter |
| src/FoodTrackerSettingTab.ts | Adds toggle controls in settings UI for each macro field |
| README.md | Documents the new toggle feature for controlling macro visibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const enabledFields = this.plugin.settings.enabledFrontmatterFields; | ||
| enabledFields[config.key] = value; | ||
| this.plugin.settingsService.updateEnabledFrontmatterFields(enabledFields); |
There was a problem hiding this comment.
This code directly mutates this.plugin.settings.enabledFrontmatterFields by reference. Line 190 creates a reference to the object, and line 191 mutates it before passing to updateEnabledFrontmatterFields. This should create a new object instead to avoid unintended side effects. Change line 190-191 to pass a new object with just the changed field: this.plugin.settingsService.updateEnabledFrontmatterFields({ [config.key]: value })
| const enabledFields = this.plugin.settings.enabledFrontmatterFields; | |
| enabledFields[config.key] = value; | |
| this.plugin.settingsService.updateEnabledFrontmatterFields(enabledFields); | |
| this.plugin.settingsService.updateEnabledFrontmatterFields({ [config.key]: value }); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9063941c1a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add toggles for each macro (calories, fats, protein, etc.) to enable/disable
their display in daily note properties. Users who only track certain macros
can now disable the others to reduce clutter from zeros in their daily notes.