diff --git a/src/card.ts b/src/card.ts index 8dae132e..8b9065bd 100644 --- a/src/card.ts +++ b/src/card.ts @@ -129,7 +129,12 @@ export class Card extends LitElement { const newEntityId = (event as CustomEvent).detail.entityId; if (newEntityId !== this.activePlayerId) { this.activePlayerId = newEntityId; - this.requestUpdate(); + try { + this.requestUpdate(); + } catch (e) { + console.error('Error updating card. newEntityId:',newEntityId); + console.error(e); + } } }; diff --git a/src/editor/base-editor.ts b/src/editor/base-editor.ts index 7d68cc52..6f74d687 100644 --- a/src/editor/base-editor.ts +++ b/src/editor/base-editor.ts @@ -31,7 +31,12 @@ export abstract class BaseEditor extends LitElement { protected configChanged() { fireEvent(this, 'config-changed', { config: this.config }); - this.requestUpdate(); + try { + this.requestUpdate(); + } catch (e) { + console.error('config changed'); + console.error(e); + } } protected dispatchClose() { return this.dispatchEvent(new CustomEvent('closed')); diff --git a/src/sections/media-browser.ts b/src/sections/media-browser.ts index 7e60c999..229ffbd9 100755 --- a/src/sections/media-browser.ts +++ b/src/sections/media-browser.ts @@ -77,9 +77,11 @@ export class MediaBrowser extends LitElement { ...(this.config.customSources?.all?.map(MediaBrowser.createSource) || []), ...allFavorites, ]; + console.log('Custom Sonos Card: allFavorites', allFavorites); allFavorites = this.config.numberOfFavoritesToShow ? allFavorites.slice(0, this.config.numberOfFavoritesToShow) : allFavorites; + console.log('Custom Sonos Card: allFavorites after slicing', allFavorites); return allFavorites; } diff --git a/src/sections/volumes.ts b/src/sections/volumes.ts index 406824fe..39653c0c 100755 --- a/src/sections/volumes.ts +++ b/src/sections/volumes.ts @@ -67,7 +67,12 @@ class Volumes extends LitElement { } private toggleShowSwitches(player: MediaPlayer) { this.showSwitches[player.id] = !this.showSwitches[player.id]; - this.requestUpdate(); + try { + this.requestUpdate(); + } catch (e) { + console.error('Error updating volumes'); + console.error(e); + } } private async getAdditionalControls(hide: boolean, player: MediaPlayer) { diff --git a/src/services/media-browse-service.ts b/src/services/media-browse-service.ts index 3f3981e4..27d57608 100644 --- a/src/services/media-browse-service.ts +++ b/src/services/media-browse-service.ts @@ -11,14 +11,21 @@ export default class MediaBrowseService { } async getAllFavorites(mediaPlayers: MediaPlayer[], ignoredTitles?: string[]): Promise { + console.log('Custom Sonos Card: getting all favorites', mediaPlayers, ignoredTitles); if (!mediaPlayers.length) { return []; } const favoritesForAllPlayers = await Promise.all(mediaPlayers.map((player) => this.getFavoritesForPlayer(player))); + console.log('Custom Sonos Card: favoritesForAllPlayers', favoritesForAllPlayers); let favorites = favoritesForAllPlayers.flatMap((f) => f); + console.log('Custom Sonos Card: favorites', favorites); favorites = this.removeDuplicates(favorites); + console.log('Custom Sonos Card: favorites after removing duplicates', favorites); favorites = favorites.length ? favorites : this.getFavoritesFromStates(mediaPlayers); - return favorites.filter((item) => indexOfWithoutSpecialChars(ignoredTitles ?? [], item.title) === -1); + console.log('Custom Sonos Card: favorites after getting from states', favorites); + const filtered = favorites.filter((item) => indexOfWithoutSpecialChars(ignoredTitles ?? [], item.title) === -1); + console.log('Custom Sonos Card: favorites after filtering', filtered); + return filtered; } private removeDuplicates(items: MediaPlayerItem[]) {