mirror of https://github.com/snachodog/mybuddy.git
Dashboard: Auto-refresh even if focus is supported
* No change if unsupported * If supported, still auto-refresh at the selected frequency (if any), but only if not hidden. This is useful for always-on displays (e.g. a "baby clock"). Fixes #253
This commit is contained in:
parent
411641903f
commit
798d7663fd
|
@ -18,8 +18,8 @@ class Settings(models.Model):
|
||||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||||
dashboard_refresh_rate = models.DurationField(
|
dashboard_refresh_rate = models.DurationField(
|
||||||
verbose_name=_('Refresh rate'),
|
verbose_name=_('Refresh rate'),
|
||||||
help_text=_('This setting will only be used when a browser does not '
|
help_text=_('If supported by browser, the dashboard will only refresh '
|
||||||
'support refresh on focus.'),
|
'when visible, and also when receiving focus.'),
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
default=timezone.timedelta(minutes=1),
|
default=timezone.timedelta(minutes=1),
|
||||||
|
|
|
@ -34,6 +34,9 @@ BabyBuddy.Dashboard = function ($) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.addEventListener('focus', Dashboard.handleVisibilityChange, false);
|
window.addEventListener('focus', Dashboard.handleVisibilityChange, false);
|
||||||
|
if (refresh_rate) {
|
||||||
|
runIntervalId = setInterval(Dashboard.handleVisibilityChange, refresh_rate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,9 @@ BabyBuddy.Dashboard = function ($) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.addEventListener('focus', Dashboard.handleVisibilityChange, false);
|
window.addEventListener('focus', Dashboard.handleVisibilityChange, false);
|
||||||
|
if (refresh_rate) {
|
||||||
|
runIntervalId = setInterval(Dashboard.handleVisibilityChange, refresh_rate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -207,6 +207,9 @@ BabyBuddy.Dashboard = function ($) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.addEventListener('focus', Dashboard.handleVisibilityChange, false);
|
window.addEventListener('focus', Dashboard.handleVisibilityChange, false);
|
||||||
|
if (refresh_rate) {
|
||||||
|
runIntervalId = setInterval(Dashboard.handleVisibilityChange, refresh_rate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue