Fix: Edge case on Windows where only one poster in horizontal scroll was displayed

music 3.0.6
Juraj Nyíri 3 years ago
parent 7fee53aa94
commit 3b9dae5c14

@ -21543,6 +21543,7 @@ style.textContent = css `
class PlexMeetsHomeAssistant extends HTMLElement { class PlexMeetsHomeAssistant extends HTMLElement {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.renderPageRetries = 0;
this.searchInputElem = document.createElement('input'); this.searchInputElem = document.createElement('input');
this.plexProtocol = 'http'; this.plexProtocol = 'http';
this.useHorizontalScroll = false; this.useHorizontalScroll = false;
@ -21994,13 +21995,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
else { else {
this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) + this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) +
getWidth(movieElem) + getWidth(movieElem) +
10}px`; 10.15}px`;
} }
} }
this.renderedItems += 1; this.renderedItems += 1;
} }
} }
if (shouldRender && lastRowTop !== movieElem.getBoundingClientRect().top) { if (shouldRender && lastRowTop !== movieElem.getBoundingClientRect().top && !this.useHorizontalScroll) {
this.renderedRows += 1; this.renderedRows += 1;
if (lastRowTop !== 0 && this.columnsCount === 0) { if (lastRowTop !== 0 && this.columnsCount === 0) {
this.columnsCount = this.renderedItems - 1; this.columnsCount = this.renderedItems - 1;
@ -22010,14 +22011,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * loadAdditionalRowsCount; this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * loadAdditionalRowsCount;
} }
} }
if (this.maxRows && this.renderedRows > this.maxRows) { if (this.maxRows && this.renderedRows > this.maxRows && !this.useHorizontalScroll) {
movieElem.remove(); movieElem.remove();
} }
return true; return true;
} }
return false; return false;
}); });
this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) + 5}px`;
} }
const contentbg = this.getElementsByClassName('contentbg')[0]; const contentbg = this.getElementsByClassName('contentbg')[0];
this.contentBGHeight = getHeight(contentbg); this.contentBGHeight = getHeight(contentbg);
@ -22041,10 +22041,15 @@ class PlexMeetsHomeAssistant extends HTMLElement {
CSS_STYLE.episodeWidth = Math.floor(areaSize / episodesInRow - marginRight); CSS_STYLE.episodeWidth = Math.floor(areaSize / episodesInRow - marginRight);
CSS_STYLE.episodeHeight = Math.round(CSS_STYLE.episodeWidth * CSS_STYLE.episodeRatio); CSS_STYLE.episodeHeight = Math.round(CSS_STYLE.episodeWidth * CSS_STYLE.episodeRatio);
} }
else { else if (this.renderPageRetries < 10) {
setTimeout(() => { {
this.renderPage(); // sometimes it loop forever, todo: properly fix!
}, 250); setTimeout(() => {
this.renderPageRetries += 1;
console.log('retry');
this.renderPage();
}, 250);
}
} }
} }
this.renderedItems = 0; this.renderedItems = 0;

@ -30,6 +30,8 @@ declare global {
} }
class PlexMeetsHomeAssistant extends HTMLElement { class PlexMeetsHomeAssistant extends HTMLElement {
renderPageRetries = 0;
searchInputElem = document.createElement('input'); searchInputElem = document.createElement('input');
plexProtocol: 'http' | 'https' = 'http'; plexProtocol: 'http' | 'https' = 'http';
@ -607,14 +609,14 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} else { } else {
this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) + this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) +
getWidth(movieElem) + getWidth(movieElem) +
10}px`; 10.15}px`;
} }
} }
this.renderedItems += 1; this.renderedItems += 1;
} }
} }
if (shouldRender && lastRowTop !== movieElem.getBoundingClientRect().top) { if (shouldRender && lastRowTop !== movieElem.getBoundingClientRect().top && !this.useHorizontalScroll) {
this.renderedRows += 1; this.renderedRows += 1;
if (lastRowTop !== 0 && this.columnsCount === 0) { if (lastRowTop !== 0 && this.columnsCount === 0) {
this.columnsCount = this.renderedItems - 1; this.columnsCount = this.renderedItems - 1;
@ -624,14 +626,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * loadAdditionalRowsCount; this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * loadAdditionalRowsCount;
} }
} }
if (this.maxRows && this.renderedRows > this.maxRows) { if (this.maxRows && this.renderedRows > this.maxRows && !this.useHorizontalScroll) {
movieElem.remove(); movieElem.remove();
} }
return true; return true;
} }
return false; return false;
}); });
this.contentContainer.style.width = `${parseFloat(this.contentContainer.style.width) + 5}px`;
} }
const contentbg = this.getElementsByClassName('contentbg')[0] as HTMLElement; const contentbg = this.getElementsByClassName('contentbg')[0] as HTMLElement;
@ -658,8 +659,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
CSS_STYLE.episodeWidth = Math.floor(areaSize / episodesInRow - marginRight); CSS_STYLE.episodeWidth = Math.floor(areaSize / episodesInRow - marginRight);
CSS_STYLE.episodeHeight = Math.round(CSS_STYLE.episodeWidth * CSS_STYLE.episodeRatio); CSS_STYLE.episodeHeight = Math.round(CSS_STYLE.episodeWidth * CSS_STYLE.episodeRatio);
} else { } else if (this.renderPageRetries < 10) {
// sometimes it loop forever, todo: properly fix!
setTimeout(() => { setTimeout(() => {
this.renderPageRetries += 1;
this.renderPage(); this.renderPage();
}, 250); }, 250);
} }

Loading…
Cancel
Save