Skip to content

Commit

Permalink
[ 1.0.11 ] * Fixed a bug in all media list rendering controls that wa…
Browse files Browse the repository at this point in the history
…s causing the media list not to render for some browser types (Fire HD, iPad Air, etc).

  * Replaced all `lastupdatedon` properties with `date_last_refreshed` property that is populated by the spotifywebapiPython package.
  • Loading branch information
thlucas1 committed Nov 4, 2024
1 parent 20d1c34 commit 862445d
Show file tree
Hide file tree
Showing 33 changed files with 326 additions and 224 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Change are listed in reverse chronological order (newest to oldest).

<span class="changelog">

###### [ 1.0.11 ] - 2024/11/04

* Fixed a bug in all media list rendering controls that was causing the media list not to render for some browser types (Fire HD, iPad Air, etc).
* Replaced all `lastupdatedon` properties with `date_last_refreshed` property that is populated by the spotifywebapiPython package.

###### [ 1.0.10 ] - 2024/11/03

* This release requires the SpotifyPlus v1.0.64 release; please make sure you update the SpotifyPlus integration prior to updating this SpotifyPlus Card release.
Expand Down
11 changes: 11 additions & 0 deletions src/components/artist-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { property, state } from 'lit/decorators.js';
import copyTextToClipboard from 'copy-text-to-clipboard';
import {
mdiAccountMusic,
mdiAlbum,
mdiClipboardPlusOutline,
mdiHeart,
mdiHeartOutline,
Expand Down Expand Up @@ -36,6 +37,7 @@ enum Actions {
ArtistFavoriteAdd = "ArtistFavoriteAdd",
ArtistFavoriteRemove = "ArtistFavoriteRemove",
ArtistFavoriteUpdate = "ArtistFavoriteUpdate",
ArtistSearchAlbums = "ArtistSearchAlbums",
ArtistSearchPlaylists = "ArtistSearchPlaylists",
ArtistSearchRadio = "ArtistSearchRadio",
ArtistSearchTracks = "ArtistSearchTracks",
Expand Down Expand Up @@ -114,6 +116,10 @@ class ArtistActions extends FavActionsBase {
<ha-assist-chip slot="trigger">
<ha-svg-icon slot="icon" .path=${mdiDotsHorizontal}></ha-svg-icon>
</ha-assist-chip>
<ha-md-menu-item @click=${() => this.onClickAction(Actions.ArtistSearchAlbums)} hide=${this.hideSearchType(SearchMediaTypes.ALBUMS)}>
<ha-svg-icon slot="start" .path=${mdiAlbum}></ha-svg-icon>
<div slot="headline">Search for Artist Albums</div>
</ha-md-menu-item>
<ha-md-menu-item @click=${() => this.onClickAction(Actions.ArtistSearchPlaylists)} hide=${this.hideSearchType(SearchMediaTypes.PLAYLISTS)}>
<ha-svg-icon slot="start" .path=${mdiPlaylistPlay}></ha-svg-icon>
<div slot="headline">Search Playlists for Artist</div>
Expand Down Expand Up @@ -247,6 +253,11 @@ class ArtistActions extends FavActionsBase {
copyTextToClipboard(this.mediaItem.uri);
return true;

} else if (action == Actions.ArtistSearchAlbums) {

this.dispatchEvent(SearchMediaEvent(SearchMediaTypes.ALBUMS, this.mediaItem.name));
return true;

} else if (action == Actions.ArtistSearchPlaylists) {

this.dispatchEvent(SearchMediaEvent(SearchMediaTypes.PLAYLISTS, this.mediaItem.name));
Expand Down
34 changes: 1 addition & 33 deletions src/components/media-browser-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ export class MediaBrowserIcons extends MediaBrowserBase {

// render html.
return html`
<style>
:host {
--items-per-row: ${this.itemsPerRow};
}
</style>
<div class="icons">
<div class="icons" style="--items-per-row: ${this.itemsPerRow}">
${buildMediaBrowserItems(this.items || [], this.config, this.mediaType, this.store).map(
(item, index) => html`
${styleMediaBrowserItemBackgroundImage(item.mbi_item.image_url, index, this.mediaType)}
Expand Down Expand Up @@ -79,33 +74,6 @@ export class MediaBrowserIcons extends MediaBrowserBase {
`;
}

//${(() => {
// if (this.isTouchDevice) {
// return (html`
// <ha-control-button
// class="button"
// isTouchDevice="${this.isTouchDevice}"
// @touchstart=${() => this.onMediaBrowserItemTouchStart(customEvent(ITEM_SELECTED, item))}
// @touchend=${() => this.onMediaBrowserItemTouchEnd(customEvent(ITEM_SELECTED, item))}
// >
// ${renderMediaBrowserItem(item, !item.mbi_item.image_url || !this.hideTitle, !this.hideSubTitle)}
// </ha-control-button>
// `);
// } else {
// return (html`
// <ha-control-button
// class="button"
// isTouchDevice="${this.isTouchDevice}"
// @click=${() => this.onMediaBrowserItemClick(customEvent(ITEM_SELECTED, item))}
// @mousedown=${() => this.onMediaBrowserItemMouseDown()}
// @mouseup=${() => this.onMediaBrowserItemMouseUp(customEvent(ITEM_SELECTED, item))}
// >
// ${renderMediaBrowserItem(item, !item.mbi_item.image_url || !this.hideTitle, !this.hideSubTitle)}
// </ha-control-button>
// `);
// }
//})()}


/**
* Style definitions used by this card section.
Expand Down
7 changes: 1 addition & 6 deletions src/components/media-browser-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@ export class MediaBrowserList extends MediaBrowserBase {

// render html.
return html`
<style>
:host {
--items-per-row: ${this.itemsPerRow};
}
</style>
<mwc-list multi class="list">
<mwc-list multi class="list" style="--items-per-row: ${this.itemsPerRow}">
${buildMediaBrowserItems(this.items || [], this.config, this.mediaType, this.store).map((item, index) => {
return html`
${styleMediaBrowserItemBackgroundImage(item.mbi_item.image_url, index, this.mediaType)}
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from 'lit';

/** current version of the card. */
export const CARD_VERSION = '1.0.10';
export const CARD_VERSION = '1.0.11';

/** SpotifyPlus integration domain identifier. */
export const DOMAIN_SPOTIFYPLUS = 'spotifyplus';
Expand Down
2 changes: 1 addition & 1 deletion src/sections/album-fav-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class AlbumFavBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = GetAlbums(result);
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/artist-fav-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class ArtistFavBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = result.items;
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/audiobook-fav-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class AudiobookFavBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = result.items;
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/device-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class DeviceBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = result.Items;
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.DateLastRefreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/episode-fav-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class EpisodeFavBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = GetEpisodes(result);
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/playlist-fav-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class PlaylistFavBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = result.items;
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/recent-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class RecentBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = GetTracks(result);
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/search-media-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export class SearchBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = result.items as [any];
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// clear certain info messsages if they are temporary.
if (this.alertInfo?.startsWith("Searching Spotify")) {
Expand Down
2 changes: 1 addition & 1 deletion src/sections/show-fav-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class ShowFavBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = GetShows(result);
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
2 changes: 1 addition & 1 deletion src/sections/track-fav-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class TrackFavBrowser extends FavBrowserBase {

// load media list results.
this.mediaList = GetTracks(result);
this.mediaListLastUpdatedOn = result.lastUpdatedOn || (Date.now() / 1000);
this.mediaListLastUpdatedOn = result.date_last_refreshed || (Date.now() / 1000);

// call base class method, indicating media list update succeeded.
super.updatedMediaListOk();
Expand Down
Loading

0 comments on commit 862445d

Please sign in to comment.