Skip to content

Commit

Permalink
fix: refactor mediaBrowserItemsPerRow, try 2
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Sep 18, 2024
1 parent 54d525d commit 03d4e19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ export class Card extends LitElement {
} else {
this.section = PLAYER;
}
newConfig.mediaBrowserItemsPerRow = newConfig.mediaBrowserItemsPerRow || 4;
const itemsPerRow = parseInt(newConfig.mediaBrowserItemsPerRow);
newConfig.mediaBrowserItemsPerRow = isNaN(itemsPerRow) ? 4 : itemsPerRow;
this.config = newConfig;
}

Expand Down
4 changes: 2 additions & 2 deletions src/sections/media-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class MediaBrowser extends LitElement {
until(
this.getFavorites(this.activePlayer).then((items) => {
if (items?.length) {
const showFavoritesAsIcons = (this.config.mediaBrowserItemsPerRow ?? 4) > 1;
if (showFavoritesAsIcons) {
const itemsPerRow = this.config.mediaBrowserItemsPerRow || 4;
if (itemsPerRow > 1) {
return html`
<sonos-media-browser-icons
.items=${items}
Expand Down

0 comments on commit 03d4e19

Please sign in to comment.