Skip to content

Commit

Permalink
Update up-next text when auto play next episode is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorS1110 committed Jun 10, 2024
1 parent 5d18bdf commit 1b4f5a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 16 additions & 6 deletions src/components/upnextdialog/upnextdialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import layoutManager from '../layoutManager';
import focusManager from '../focusManager';
import globalize from '../../scripts/globalize';
import itemHelper from '../itemHelper';
import ServerConnections from '../ServerConnections';
import './upnextdialog.scss';
import '../../elements/emby-button/emby-button';
import '../../styles/flexstyles.scss';
Expand Down Expand Up @@ -54,9 +55,9 @@ function setNextVideoText() {

const timeText = '<span class="upNextDialog-countdownText">' + globalize.translate('HeaderSecondsValue', secondsRemaining) + '</span>';

const nextVideoText = instance.itemType === 'Episode' ?
globalize.translate('HeaderNextEpisodePlayingInValue', timeText) :
globalize.translate('HeaderNextVideoPlayingInValue', timeText);
const nextVideoText = instance.showStaticNextText ?
globalize.translate('HeaderNextItem', instance.itemType) :
globalize.translate('HeaderNextItemPlayingInValue', instance.itemType, timeText);

elem.querySelector('.upNextDialog-nextVideoText').innerHTML = nextVideoText;
}
Expand Down Expand Up @@ -104,7 +105,9 @@ async function onStartNowClick() {
}
}

function init(instance, options) {
async function init(instance, options) {
instance.showStaticNextText = await showStaticNextText(options.nextItem);

options.parent.innerHTML = getHtml();

options.parent.classList.add('hide');
Expand Down Expand Up @@ -199,12 +202,19 @@ function startComingUpNextHideTimer(instance) {
setNextVideoText.call(instance);
clearCountdownTextTimeout(instance);

instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
if (!instance.showStaticNextText) instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
}

async function showStaticNextText(nextItem) {
const apiClient = ServerConnections.getApiClient(nextItem);
const currentUser = await apiClient.getCurrentUser();
return !currentUser.Configuration.EnableNextEpisodeAutoPlay;
}

class UpNextDialog {
constructor(options) {
this.options = options;
this.showStaticNextText = false; // default to showing countdown text

init(this, options);
}
Expand Down Expand Up @@ -235,9 +245,9 @@ class UpNextDialog {
hideComingUpNext.call(this);

this.options = null;
this.showStaticNextText = false;
this.itemType = null;
}
}

export default UpNextDialog;

4 changes: 2 additions & 2 deletions src/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@
"HeaderNewApiKey": "New API Key",
"HeaderNewDevices": "New Devices",
"HeaderNewRepository": "New Repository",
"HeaderNextEpisodePlayingInValue": "Next Episode Playing in {0}",
"HeaderNextVideoPlayingInValue": "Next Video Playing in {0}",
"HeaderNextItem": "Next {0}",
"HeaderNextItemPlayingInValue": "Next {0} Playing in {1}",
"HeaderNoLyrics": "No lyrics found",
"HeaderOnNow": "On Now",
"HeaderOtherItems": "Other Items",
Expand Down

0 comments on commit 1b4f5a4

Please sign in to comment.