Skip to content

Commit

Permalink
Delay monitors stopping for 15 seconds when hiding page (montage.js)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorA100 authored May 31, 2024
1 parent 3c8ebc8 commit 2123a56
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions web/skins/classic/views/js/montage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,15 @@ $j(window).on('load', () => initPage());

document.onvisibilitychange = () => {
if (document.visibilityState === "hidden") {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
TimerHideShow = clearTimeout(TimerHideShow);
TimerHideShow = setTimeout(function() {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
}, 15*1000);
} else {
TimerHideShow = clearTimeout(TimerHideShow);
//Start monitors when show page
for (let i = 0, length = monitorData.length; i < length; i++) {
if (!monitors[i].started) {
Expand All @@ -1119,6 +1123,7 @@ document.onvisibilitychange = () => {
}
};


/*
window.onbeforeunload = function(e) {
console.log('unload');
Expand Down

3 comments on commit 2123a56

@Simpler1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit is producing the following errors in dark mode:
image

@Simpler1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's just missing the following line at the top of the file:
var TimerHideShow;

@IgorA100
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the variable definition was lost in my commit, but Isaac has already corrected it.
Thank you.

Please sign in to comment.