From bfea31c9a706dbe3de7933f08fa6512c4e212dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sun, 6 Jun 2021 17:44:40 +0200 Subject: [PATCH] Fix: Round ratings to 1 decimal --- dist/plex-meets-homeassistant.js | 3 ++- src/plex-meets-homeassistant.ts | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index eca9bac..4706d10 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -20252,6 +20252,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.detailElem.children[0].innerHTML = escapeHtml(data.title); this.detailElem.children[1].innerHTML = escapeHtml(data.year); this.detailElem.children[1].dataset.year = escapeHtml(data.year); + console.log(data.rating); this.detailElem.children[2].innerHTML = `${(data.duration !== undefined ? `${Math.round(parseInt(escapeHtml(data.duration), 10) / 60 / 1000)} min` : '') + @@ -20259,7 +20260,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { ? `${escapeHtml(data.contentRating)}` : '') + (data.rating !== undefined - ? `${data.rating < 5 ? '🗑' : '⭐'} ${escapeHtml(data.rating)}` + ? `${data.rating < 5 ? '🗑' : '⭐'} ${Math.round(parseFloat(escapeHtml(data.rating)) * 10) / 10}` : '')}
`; this.detailElem.children[3].innerHTML = escapeHtml(data.summary); /* todo temp disabled diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 1057072..7f03c53 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -616,6 +616,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.detailElem.children[0].innerHTML = escapeHtml(data.title); this.detailElem.children[1].innerHTML = escapeHtml(data.year); (this.detailElem.children[1] as HTMLElement).dataset.year = escapeHtml(data.year); + console.log(data.rating); this.detailElem.children[2].innerHTML = `${(data.duration !== undefined ? `${Math.round( parseInt(escapeHtml(data.duration), 10) / 60 / 1000 @@ -625,9 +626,9 @@ class PlexMeetsHomeAssistant extends HTMLElement { ? `${escapeHtml(data.contentRating)}` : '') + (data.rating !== undefined - ? `${data.rating < 5 ? '🗑' : '⭐'} ${escapeHtml( - data.rating - )}` + ? `${data.rating < 5 ? '🗑' : '⭐'} ${Math.round( + parseFloat(escapeHtml(data.rating)) * 10 + ) / 10}` : '')}
`; this.detailElem.children[3].innerHTML = escapeHtml(data.summary); /* todo temp disabled