Skip to content

media_player: only add a separating colon if there is a valid prefix and suffix#2060

Merged
balloob merged 1 commit intohome-assistant:devfrom
jackwilsdon:fix-magic-colon
Nov 19, 2018
Merged

media_player: only add a separating colon if there is a valid prefix and suffix#2060
balloob merged 1 commit intohome-assistant:devfrom
jackwilsdon:fix-magic-colon

Conversation

@jackwilsdon
Copy link
Copy Markdown
Contributor

@jackwilsdon jackwilsdon commented Nov 16, 2018

This PR changes the media player entity row to only add a colon separator to the status line when there is both a prefix and a suffix.

This issue affected my Sonos device, displaying a colon when there is nothing playing (and also when using TTS);

Old New
Media player card displaying erroneous colon Media player card displaying correctly

This change only affects the Lovelace UI.

@jackwilsdon
Copy link
Copy Markdown
Contributor Author

I do have one note; I could condense this logic here;

https://github.com/home-assistant/home-assistant-polymer/blob/fdceb9dc52c985903b6f742852e7e9ef1fa49bb5/src/panels/lovelace/entity-rows/hui-media-player-entity-row.js#L126-L139

By changing it to something like this;

    if (prefix && suffix) {
      return `${prefix}: ${suffix}`;
    }

    // Return the concatenated prefix and suffix, using an empty string if either are missing.
    return (prefix || "") + (suffix || "");

But I'm not sure if that is as clear / expressive of what it's trying to achieve.

@jackwilsdon
Copy link
Copy Markdown
Contributor Author

It looks like this PR also fixes the "undefined" issue I've been having on my Apple TV;

Old New
screen shot 2018-11-16 at 20 12 05 screen shot 2018-11-16 at 20 12 35

@zsarnett
Copy link
Copy Markdown
Contributor

This is Much cleaner now. Great Job!

@jackwilsdon
Copy link
Copy Markdown
Contributor Author

Cheers!

This commit changes the media player entity row to only add a colon
separator to the status line when there is both a prefix and a suffix.
@balloob balloob merged commit 1bb62bf into home-assistant:dev Nov 19, 2018
@ghost ghost removed the in progress label Nov 19, 2018
@jackwilsdon jackwilsdon deleted the fix-magic-colon branch November 19, 2018 12:23
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants