From ca5c66775a1c5d7928931cfead8ae4ac9d7b479a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 8 Apr 2021 19:54:49 +0300 Subject: show git version in the UI --- js/app.js | 4 +++- js/reader.js | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'js') diff --git a/js/app.js b/js/app.js index 0eaa5aa..02a6fb7 100644 --- a/js/app.js +++ b/js/app.js @@ -39,6 +39,7 @@ const App = { _dl_progress_timeout: false, index_mode: "", last_mtime: -1, + version: "UNKNOWN", csrf_token: "", init: function() { let refreshed_files = 0; @@ -97,6 +98,7 @@ const App = { if (event.data == 'client-reload') { localforage.setItem("epube.cache-timestamp", App.last_mtime); + localforage.setItem("epube.cache-version", App.version); window.location.reload() } @@ -183,7 +185,7 @@ const App = { refreshCache: function(force) { if ('serviceWorker' in navigator) { localforage.getItem("epube.cache-timestamp").then(function(stamp) { - console.log('stamp', stamp, 'last mtime', App.last_mtime); + console.log('stamp', stamp, 'last mtime', App.last_mtime, 'version', App.version); if (force || stamp != App.last_mtime) { console.log('asking worker to refresh cache'); diff --git a/js/reader.js b/js/reader.js index b1db806..a38513e 100644 --- a/js/reader.js +++ b/js/reader.js @@ -322,17 +322,17 @@ const Reader = { }); }); - localforage.getItem("epube.cache-timestamp").then(function(stamp) { - let msg = "V: "; - - if (parseInt(stamp)) - msg += new Date(stamp*1000).toLocaleString("en-GB"); - else - msg += "Unknown"; - - msg += " (" + (App.isOnline() ? "Online" : "Offline") + ")"; - - $(".last-mod-timestamp").text(msg) + Promise.all([ + localforage.getItem("epube.cache-timestamp"), + localforage.getItem("epube.cache-version") + ]).then((res) => { + const stamp = res[0]; + const version = res[1]; + + $(".last-mod-timestamp").html(`${version} + — ${parseInt(stamp) ? new Date(stamp*1000).toLocaleString("en-GB") : "Unknown"} + (${App.isOnline() ? `Online` : `Offline`}) + `); }); localforage.getItem("epube.fontFamily").then(function(font) { -- cgit v1.2.3