mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-06 06:07:29 +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,
|
global_unread: -1,
|
||||||
_widescreen_mode: false,
|
_widescreen_mode: false,
|
||||||
_loading_progress: 0,
|
_loading_progress: 0,
|
||||||
|
_night_mode_retry_timeout: false,
|
||||||
hotkey_actions: {},
|
hotkey_actions: {},
|
||||||
is_prefs: false,
|
is_prefs: false,
|
||||||
LABEL_BASE_INDEX: -1024,
|
LABEL_BASE_INDEX: -1024,
|
||||||
@ -167,12 +168,25 @@ const App = {
|
|||||||
setInitParam: function(k, v) {
|
setInitParam: function(k, v) {
|
||||||
this._initParams[k] = v;
|
this._initParams[k] = v;
|
||||||
},
|
},
|
||||||
nightModeChanged: function(is_night, link) {
|
nightModeChanged: function(is_night, link, retry = 0) {
|
||||||
console.log("night mode changed to", is_night);
|
console.log("nightModeChanged: night mode changed to", is_night, "retry", retry);
|
||||||
|
|
||||||
if (link) {
|
if (link) {
|
||||||
const css_override = is_night ? "themes/night.css" : "themes/light.css";
|
if (navigator.onLine) {
|
||||||
link.setAttribute("href", css_override + "?" + Date.now());
|
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) {
|
setupNightModeDetection: function(callback) {
|
||||||
|
Loading…
Reference in New Issue
Block a user