mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-05 13:47:25 +02:00
Merge branch 'retry-night-mode-switch' into 'master'
attempt to retry night mode switch if we're offline See merge request tt-rss/tt-rss!167
This commit is contained in:
commit
8b07dc8453
22
js/App.js
22
js/App.js
@ -14,6 +14,7 @@ const App = {
|
||||
global_unread: -1,
|
||||
_widescreen_mode: false,
|
||||
_loading_progress: 0,
|
||||
_night_mode_retry_timeout: false,
|
||||
hotkey_actions: {},
|
||||
is_prefs: false,
|
||||
LABEL_BASE_INDEX: -1024,
|
||||
@ -167,12 +168,25 @@ const App = {
|
||||
setInitParam: function(k, v) {
|
||||
this._initParams[k] = v;
|
||||
},
|
||||
nightModeChanged: function(is_night, link) {
|
||||
console.log("night mode changed to", is_night);
|
||||
nightModeChanged: function(is_night, link, retry = 0) {
|
||||
console.log("nightModeChanged: night mode changed to", is_night, "retry", retry);
|
||||
|
||||
if (link) {
|
||||
const css_override = is_night ? "themes/night.css" : "themes/light.css";
|
||||
link.setAttribute("href", css_override + "?" + Date.now());
|
||||
if (navigator.onLine) {
|
||||
const css_override = is_night ? "themes/night.css" : "themes/light.css";
|
||||
link.setAttribute("href", css_override + "?" + Date.now());
|
||||
} else if (retry < 5) {
|
||||
console.log("nightModeChanged: we're offline, will attempt to retry...");
|
||||
|
||||
window.clearTimeout(this._night_mode_retry_timeout);
|
||||
|
||||
this._night_mode_retry_timeout = window.setTimeout(
|
||||
() => this.nightModeChanged(is_night, link, ++retry),
|
||||
3000);
|
||||
|
||||
} else {
|
||||
console.log("nightModeChanged: too many retries, giving up");
|
||||
}
|
||||
}
|
||||
},
|
||||
setupNightModeDetection: function(callback) {
|
||||
|
Loading…
Reference in New Issue
Block a user