Add show_confirmation_toasts option to silence routine confirmations - #55
Closed
tocDK wants to merge 1 commit into
Closed
Add show_confirmation_toasts option to silence routine confirmations#55tocDK wants to merge 1 commit into
tocDK wants to merge 1 commit into
Conversation
Adds a new opt-in setting that, when disabled, suppresses info + success toast variants — the routine confirmation messages like "Player Selected" or "Added to liked" that briefly cover other UI controls (volume slider, transport buttons). Error toasts always show regardless, so genuine failures stay visible. The setting is exposed in three places that all share the same effect: - YAML / visual editor (config): show_confirmation_toasts: true|false (default true — existing behavior preserved) - In-card Settings panel (Display section): an Enabled / Disabled pill the user can flip without editing YAML. Persisted per browser in localStorage as homeii_music_flow_mobile_show_confirmation_toasts. The in-card toggle takes precedence over the YAML default once the user has touched it (any concrete state value wins; undefined falls back to config). Matches the pattern users expect: install with a default, opt out from the card itself if it gets in the way. Wiring: - src/core/base-music-card.js: small gate at the top of _toast() that checks state, falls back to config, and early-returns for non-error variants when the effective decision is "do not show". A comment explains why the precedence is inlined rather than calling the subclass helper. - src/config/validators.js: assertBooleanIfDefined for the new field. - src/config/editor-forms.js: visual editor field in both base and mobile card forms, alongside hotel_mode. - src/homeii-music-flow.js: state init, localStorage hydrate, helper _showConfirmationToasts(), pill HTML in the Display section of _settingsMenuHtml, click handler in _handleMobileMenuClick, and the persist line in _persistMobileAppearance. - src/localization/*.js: ui.show_confirmation_toasts and ui.show_confirmation_toasts_helper added to all 8 bundled locales. English and Danish are native; the other 6 (es, fr, he, it, lt, zh) are DeepL with "player" hand-corrected away from sports-player. - tests/config-validation.test.js: new option added to the valid-fixture and a rejects-invalid test mirroring the hotel_mode pattern. Default behavior is unchanged. Existing users see no difference until they explicitly disable the option. Validated end-to-end on a dev HA: with the option enabled (default), all three toast variants render normally; with it disabled (via the Settings pill), info and success are suppressed and only error toasts render; the localStorage value survives a page reload and overrides the config default if the two disagree. Full vitest suite (134/134) passes, lint passes, vite build clean. Refs r11a#54
Owner
|
Thank you for this PR. The issue behind it is handled differently in 5.9.0: the player-selected confirmation toast was moved so it no longer covers the volume slider. For now I’m not adding a new global toast-disable setting, because I want to avoid adding another option unless users still need it after the 5.9.0 change. I’m closing this one without merging, but if the new behavior is still not enough, we can revisit this idea later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #54
This is a suggestion, not a fix
The original issue asks for an "off switch" for the routine confirmation toasts that cover other UI controls (the screenshot shows "Player Selected" eating the volume slider). This PR adds that off switch
as an opt-in setting exposed in YAML, the visual editor, and the in-card Settings panel. Default keeps existing behavior. Happy to drop / rename / re-scope on review.
What the option does
show_confirmation_toasts(defaulttrue, matches existing behavior).false, the central_toast()method short-circuits anyinfoorsuccessvariant. Error toasts always render regardless, so genuine failures stay visible._toast()insrc/core/base-music-card.js— all existing call sites (~60 across the codebase) inherit the behavior with no churn.Three surfaces, one effect
show_confirmation_toasts: falselocalStorageashomeii_music_flow_mobile_show_confirmation_toasts.The in-card toggle takes precedence over the YAML default once the user has touched it: a concrete state value wins; undefined falls back to config. Matches the pattern users expect — install with a
default, opt out from the card itself if it gets in the way.
Naming choice
Considered
disable_confirmation_toasts: true(negative-sense, defaultfalse) but landed onshow_confirmation_toasts: false(positive-sense, defaulttrue) so the option matches the existingconvention in the schema where every other boolean reads positively (
show_ma_button,ambient_light_enabled,mobile_show_up_next,hotel_mode).Wiring
src/config/validators.js:assertBooleanIfDefinedfor the new field.src/config/editor-forms.js: visual-editor field in both base and mobile card forms, alongsidehotel_mode, with label + helper text in the labels/helpers maps.src/homeii-music-flow.js: state init, localStorage hydration,_showConfirmationToasts()helper (state-then-config precedence), pill HTML in the Display section of_settingsMenuHtml, click handlerappended to
_handleMobileMenuClick, persist line in_persistMobileAppearance.src/core/base-music-card.js: small gate at the top of_toast()that checks state, falls back to config, and early-returns for non-error variants. Includes a comment explaining why the precedence logicis inlined here rather than delegating to the subclass helper (base class can't reach subclass methods; the two locations must change together).
src/localization/*.js: two new i18n keys (ui.show_confirmation_toasts,ui.show_confirmation_toasts_helper) in all 8 bundled locales. English and Danish are native;es,fr,he,it,lt,zhare DeepL with the recurring "player" → "media player" hand-correction (DeepL defaults to "sports player").
tests/config-validation.test.js: new option added to the valid-fixture; a rejects-invalid test (show_confirmation_toasts: "yes"→ boolean error) mirrors thehotel_modepattern.What is NOT in this PR
pointer-events: noneon the.toastelement itself, which would also fix the volume-slider blocking the original issue describes — without removing the toasts. Left out to keep this PR focused on theexplicit "off switch" the issue asks for. Happy to add as a separate change.
Validation
npm run check— 134/134 tests pass.npm run build— clean.toasts render;
localStoragepersists the choice across page reloads; the state override correctly takes precedence over the YAML default when the two disagree.Out of scope