diff --git a/dashboard-ui/bower_components/emby-webcomponents/guide/guide.js b/dashboard-ui/bower_components/emby-webcomponents/guide/guide.js index 9de47d0bda..1050c59abb 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/guide/guide.js +++ b/dashboard-ui/bower_components/emby-webcomponents/guide/guide.js @@ -38,15 +38,19 @@ var currentDate; var currentStartIndex = 0; var currentChannelLimit = 0; + var autoRefreshInterval; self.refresh = function () { currentDate = null; reloadPage(options.element); + restartAutoRefresh(); }; self.destroy = function () { + stopAutoRefresh(); + events.off(serverNotifications, 'TimerCreated', onTimerCreated); events.off(serverNotifications, 'SeriesTimerCreated', onSeriesTimerCreated); events.off(serverNotifications, 'TimerCancelled', onTimerCancelled); @@ -58,6 +62,24 @@ items = {}; }; + function restartAutoRefresh() { + + stopAutoRefresh(); + + var intervalMs = 60000 * 15; // (minutes) + + autoRefreshInterval = setInterval(function () { + self.refresh(); + }, intervalMs); + } + + function stopAutoRefresh() { + if (autoRefreshInterval) { + clearInterval(autoRefreshInterval); + autoRefreshInterval = null; + } + } + function normalizeDateToTimeslot(date) { var minutesOffset = date.getMinutes() - cellCurationMinutes; @@ -928,29 +950,35 @@ context.querySelector('.btnSelectDate').addEventListener('click', function () { selectDate(context); + restartAutoRefresh(); }); context.querySelector('.btnUnlockGuide').addEventListener('click', function () { currentStartIndex = 0; reloadPage(context); + restartAutoRefresh(); }); context.querySelector('.btnNextPage').addEventListener('click', function () { currentStartIndex += currentChannelLimit; reloadPage(context); + restartAutoRefresh(); }); context.querySelector('.btnPreviousPage').addEventListener('click', function () { currentStartIndex = Math.max(currentStartIndex - currentChannelLimit, 0); reloadPage(context); + restartAutoRefresh(); }); context.querySelector('.btnGuideViewSettings').addEventListener('click', function () { showViewSettings(self); + restartAutoRefresh(); }); context.querySelector('.btnCategories').addEventListener('click', function () { showCategoryOptions(self); + restartAutoRefresh(); }); context.classList.add('tvguide');