From 9c439650e17ae782edae635704857cb4a53dcecf Mon Sep 17 00:00:00 2001 From: FL550 Date: Tue, 4 Aug 2020 20:17:21 +0200 Subject: [PATCH] Fixes chromecast devices not shown --- src/const.ts | 2 +- src/localize/languages/en.json | 2 +- src/spotify-card.ts | 37 +++++++++++++++++++++------------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/const.ts b/src/const.ts index 01fb578..388af5b 100755 --- a/src/const.ts +++ b/src/const.ts @@ -1 +1 @@ -export const CARD_VERSION = '2.0.2'; +export const CARD_VERSION = '2.0.3'; diff --git a/src/localize/languages/en.json b/src/localize/languages/en.json index 07e73d6..33288c4 100755 --- a/src/localize/languages/en.json +++ b/src/localize/languages/en.json @@ -29,6 +29,6 @@ "filter_out_cast_devices": "Filter out chromecast devices", "spotify_entity": "Spotify media player entity", "default_device": "Default device name", - "filter_devices": "Hide devices (see documentation under 'Advanced usage' for details)" + "filter_devices": "Hide devices (see documentation under 'Advanced usage')" } } diff --git a/src/spotify-card.ts b/src/spotify-card.ts index 9ae0fc7..8900308 100755 --- a/src/spotify-card.ts +++ b/src/spotify-card.ts @@ -323,18 +323,20 @@ export class SpotifyCard extends LitElement { // Generate device list private generateDeviceList(): TemplateResult { - const spotify_connect_devices= this.spotcast_connector.devices.filter(this.checkIfAllowedToShow, this); + const spotify_connect_devices = this.spotcast_connector.devices.filter(this.checkIfAllowedToShow, this); const chromecast_devices = this.spotcast_connector.chromecast_devices.filter(this.checkIfAllowedToShow, this); if (spotify_connect_devices.length == 0 && chromecast_devices.length == 0) { return html`

No devices found

`; } return html` - ${spotify_connect_devices.length > 0 ? html`

Spotify Connect devices

` : null} - ${spotify_connect_devices.map((device) => html` this.spotifyDeviceSelected(device)}>${device.name} `)} - ${chromecast_devices.length > 0 ? html`

Chromecast devices

` : null} - ${chromecast_devices.map((device) => { - html` this.chromecastDeviceSelected(device)}>${device.friendly_name}`; - })} + ${spotify_connect_devices.length > 0 ? html`

Spotify Connect devices

` : null} + ${spotify_connect_devices.map((device) => { + return html` this.spotifyDeviceSelected(device)}>${device.name}`; + })} + ${chromecast_devices.length > 0 ? html`

Chromecast devices

` : null} + ${chromecast_devices.map((device) => { + return html` this.chromecastDeviceSelected(device)}>${device.friendly_name}`; + })} `; } @@ -411,13 +413,18 @@ export class SpotifyCard extends LitElement { const playing = this.spotify_state?.attributes.media_playlist === item.name; this.spotify_state?.attributes.media_playlist === item.name; result.push(html`
this.spotcast_connector.playUri(item.uri)}> - ${item.images.length > 0 - ? html`` - : html`
+ ${item.images.length > 0 + ? html`` + : html`
+ -
`} + +
`}
${playing ? this.generateGridIconForCurrent() @@ -591,7 +598,7 @@ export class SpotifyCard extends LitElement { static listStyles = css` ha-card { --list-item-height: 3em; - --spotify-color: #1db954; + --placeholder-padding: 4px; } .list-item { @@ -610,13 +617,15 @@ export class SpotifyCard extends LitElement { border-bottom: 0; } - .list-item > img, .list-item > svg { + .list-item > img, + .list-item > svg { height: var(--list-item-height); object-fit: contain; } .list-item > svg { - height: calc( var(--list-item-height) - 4px); + height: calc(var(--list-item-height) - var(--placeholder-padding)); + margin-right: var(--placeholder-padding); } .list-item > .icon {