From c5f2f51f810396871512244188aaf9e8541de07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 5 Jun 2021 21:16:57 +0200 Subject: [PATCH] Add: Viewed indicator for movies --- dist/plex-meets-homeassistant.js | 10 ++++++++-- src/modules/style.ts | 3 ++- src/plex-meets-homeassistant.ts | 8 +++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 4c50ca0..f47d255 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19538,7 +19538,8 @@ style.textContent = css ` .movieElem { margin-bottom: 5px; background-repeat: no-repeat; - background-size: contain; + background-size: cover; + overflow: hidden; border-radius: 5px; transition: 0.5s; position: absolute; @@ -20328,7 +20329,12 @@ class PlexMeetsHomeAssistant extends HTMLElement { }); const playButton = this.getPlayButton(); const interactiveArea = document.createElement('div'); - if (data.leafCount - data.viewedLeafCount > 0) { + if (!(data.viewCount && data.viewCount > 0) && data.type === 'movie') { + const toViewElem = document.createElement('div'); + toViewElem.className = 'toViewEpisode'; + interactiveArea.appendChild(toViewElem); + } + if (data.leafCount - data.viewedLeafCount > 0 && data.type === 'show') { const toViewElem = document.createElement('div'); toViewElem.className = 'toViewSeason'; toViewElem.innerHTML = (data.leafCount - data.viewedLeafCount).toString(); diff --git a/src/modules/style.ts b/src/modules/style.ts index b505d00..b8bace5 100644 --- a/src/modules/style.ts +++ b/src/modules/style.ts @@ -258,7 +258,8 @@ style.textContent = css` .movieElem { margin-bottom: 5px; background-repeat: no-repeat; - background-size: contain; + background-size: cover; + overflow: hidden; border-radius: 5px; transition: 0.5s; position: absolute; diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 618ccfa..6cb5942 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -867,7 +867,13 @@ class PlexMeetsHomeAssistant extends HTMLElement { const playButton = this.getPlayButton(); const interactiveArea = document.createElement('div'); - if (data.leafCount - data.viewedLeafCount > 0) { + if (!(data.viewCount && data.viewCount > 0) && data.type === 'movie') { + const toViewElem = document.createElement('div'); + toViewElem.className = 'toViewEpisode'; + interactiveArea.appendChild(toViewElem); + } + + if (data.leafCount - data.viewedLeafCount > 0 && data.type === 'show') { const toViewElem = document.createElement('div'); toViewElem.className = 'toViewSeason'; toViewElem.innerHTML = (data.leafCount - data.viewedLeafCount).toString();