mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 13:27:22 +00:00
Only add a separating colon if there is a valid prefix and suffix (#2060)
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.
This commit is contained in:
parent
f92f89e8e8
commit
1bb62bfc05
@ -103,22 +103,27 @@ class HuiMediaPlayerEntityRow extends LocalizeMixin(PolymerElement) {
|
||||
_computeMediaTitle(stateObj) {
|
||||
if (!stateObj || this._isOff(stateObj.state)) return null;
|
||||
|
||||
let prefix;
|
||||
let suffix;
|
||||
|
||||
switch (stateObj.attributes.media_content_type) {
|
||||
case "music":
|
||||
return `${stateObj.attributes.media_artist}: ${
|
||||
stateObj.attributes.media_title
|
||||
}`;
|
||||
prefix = stateObj.attributes.media_artist;
|
||||
suffix = stateObj.attributes.media_title;
|
||||
break;
|
||||
case "tvshow":
|
||||
return `${stateObj.attributes.media_series_title}: ${
|
||||
stateObj.attributes.media_title
|
||||
}`;
|
||||
prefix = stateObj.attributes.media_series_title;
|
||||
suffix = stateObj.attributes.media_title;
|
||||
break;
|
||||
default:
|
||||
return (
|
||||
prefix =
|
||||
stateObj.attributes.media_title ||
|
||||
stateObj.attributes.app_name ||
|
||||
stateObj.state
|
||||
);
|
||||
stateObj.state;
|
||||
suffix = "";
|
||||
}
|
||||
|
||||
return prefix && suffix ? `${prefix}: ${suffix}` : prefix || suffix || "";
|
||||
}
|
||||
|
||||
_computeState(state) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user