Fix: Edge case scenario where episodes would not dissappear after navigating back to seasons

pull/16/head
Juraj Nyíri 4 years ago
parent 02fc49eea4
commit 8f732cc60c

@ -19453,7 +19453,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}, 100); }, 100);
}; };
this.minimizeSeasons = () => { this.minimizeSeasons = () => {
return new Promise((resolve, reject) => {
this.seasonsElemHidden = false; this.seasonsElemHidden = false;
if (this.seasonsElem) { if (this.seasonsElem) {
lodash.forEach(this.seasonsElem.childNodes, child => { lodash.forEach(this.seasonsElem.childNodes, child => {
@ -19482,12 +19481,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
else { else {
setTimeout(() => { setTimeout(() => {
moveElem(seasonElem); moveElem(seasonElem);
resolve();
}, 100); }, 100);
} }
}); });
} }
});
}; };
this.minimizeAll = () => { this.minimizeAll = () => {
this.activeMovieElem = undefined; this.activeMovieElem = undefined;
@ -19648,7 +19645,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
seasonEpisodesCount.innerHTML = `${escapeHtml(seasonData.leafCount)} episodes`; seasonEpisodesCount.innerHTML = `${escapeHtml(seasonData.leafCount)} episodes`;
seasonContainer.append(seasonEpisodesCount); seasonContainer.append(seasonEpisodesCount);
seasonContainer.addEventListener('click', event => { seasonContainer.addEventListener('click', event => {
(async () => {
event.stopPropagation(); event.stopPropagation();
if (this.activeMovieElem) { if (this.activeMovieElem) {
if (seasonElem.dataset.clicked === 'false') { if (seasonElem.dataset.clicked === 'false') {
@ -19659,8 +19655,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
seasonElem.style.width = `${CSS_STYLE.expandedWidth}px`; seasonElem.style.width = `${CSS_STYLE.expandedWidth}px`;
seasonElem.style.height = `${CSS_STYLE.expandedHeight - 6}px`; seasonElem.style.height = `${CSS_STYLE.expandedHeight - 6}px`;
seasonElem.style.zIndex = '3'; seasonElem.style.zIndex = '3';
seasonElem.style.marginLeft = `-${getOffset(seasonElem).left - seasonElem.style.marginLeft = `-${getOffset(seasonElem).left - getOffset(this.activeMovieElem).left}px`;
getOffset(this.activeMovieElem).left}px`;
seasonTitleElem.style.color = 'rgba(255,255,255,0)'; seasonTitleElem.style.color = 'rgba(255,255,255,0)';
seasonEpisodesCount.style.color = 'rgba(255,255,255,0)'; seasonEpisodesCount.style.color = 'rgba(255,255,255,0)';
if (this.detailElem) { if (this.detailElem) {
@ -19730,7 +19725,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
})(); })();
} }
else { else {
await this.minimizeSeasons(); this.minimizeSeasons();
this.hideEpisodes(); this.hideEpisodes();
this.activeMovieElem.style.top = `${top + 16}px`; this.activeMovieElem.style.top = `${top + 16}px`;
if (this.detailElem && this.detailElem.children[1]) { if (this.detailElem && this.detailElem.children[1]) {
@ -19741,7 +19736,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
} }
} }
})();
}); });
this.seasonsElem.append(seasonContainer); this.seasonsElem.append(seasonContainer);
} }

@ -238,8 +238,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}, 100); }, 100);
}; };
minimizeSeasons = (): Promise<void> => { minimizeSeasons = (): void => {
return new Promise((resolve, reject) => {
this.seasonsElemHidden = false; this.seasonsElemHidden = false;
if (this.seasonsElem) { if (this.seasonsElem) {
_.forEach(this.seasonsElem.childNodes, child => { _.forEach(this.seasonsElem.childNodes, child => {
@ -269,12 +268,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} else { } else {
setTimeout(() => { setTimeout(() => {
moveElem(seasonElem); moveElem(seasonElem);
resolve();
}, 100); }, 100);
} }
}); });
} }
});
}; };
minimizeAll = (): void => { minimizeAll = (): void => {
@ -456,7 +453,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
seasonContainer.append(seasonEpisodesCount); seasonContainer.append(seasonEpisodesCount);
seasonContainer.addEventListener('click', event => { seasonContainer.addEventListener('click', event => {
(async (): Promise<void> => {
event.stopPropagation(); event.stopPropagation();
if (this.activeMovieElem) { if (this.activeMovieElem) {
if (seasonElem.dataset.clicked === 'false') { if (seasonElem.dataset.clicked === 'false') {
@ -471,8 +467,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
seasonElem.style.height = `${CSS_STYLE.expandedHeight - 6}px`; seasonElem.style.height = `${CSS_STYLE.expandedHeight - 6}px`;
seasonElem.style.zIndex = '3'; seasonElem.style.zIndex = '3';
seasonElem.style.marginLeft = `-${getOffset(seasonElem).left - seasonElem.style.marginLeft = `-${getOffset(seasonElem).left - getOffset(this.activeMovieElem).left}px`;
getOffset(this.activeMovieElem).left}px`;
seasonTitleElem.style.color = 'rgba(255,255,255,0)'; seasonTitleElem.style.color = 'rgba(255,255,255,0)';
seasonEpisodesCount.style.color = 'rgba(255,255,255,0)'; seasonEpisodesCount.style.color = 'rgba(255,255,255,0)';
@ -552,7 +547,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
})(); })();
} else { } else {
await this.minimizeSeasons(); this.minimizeSeasons();
this.hideEpisodes(); this.hideEpisodes();
this.activeMovieElem.style.top = `${top + 16}px`; this.activeMovieElem.style.top = `${top + 16}px`;
if (this.detailElem && (this.detailElem.children[1] as HTMLElement)) { if (this.detailElem && (this.detailElem.children[1] as HTMLElement)) {
@ -563,7 +558,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
} }
} }
})();
}); });
this.seasonsElem.append(seasonContainer); this.seasonsElem.append(seasonContainer);

Loading…
Cancel
Save