diff options
author | Andrew Dolgov <[email protected]> | 2021-04-08 14:02:47 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-04-08 14:02:47 +0300 |
commit | 0565adcbbf88ed42fac44e42694f41d225dc1119 (patch) | |
tree | d9b5546e51b346d7b9924580bff0106328a62d52 /js | |
parent | 50ddfaf18b0b9aae7768facb39a3314d23961835 (diff) |
sync remote lastread always
Diffstat (limited to 'js')
-rw-r--r-- | js/reader.js | 57 |
1 files changed, 18 insertions, 39 deletions
diff --git a/js/reader.js b/js/reader.js index dcb7c27..b1db806 100644 --- a/js/reader.js +++ b/js/reader.js @@ -58,12 +58,9 @@ const Reader = { const currentPage = parseInt(book.locations.percentageFromCfi(currentCfi) * 100); $.post("backend.php", { op: "storelastread", id: $.urlParam("id"), page: currentPage, - cfi: currentCfi, timestamp: new Date().getTime() }, function(data) { - - if (data.cfi) { - Reader.Page._last_position_sync = new Date().getTime()/1000; - } - }) + cfi: currentCfi, timestamp: new Date().getTime() }, function() { + // + }) .fail(function(e) { if (e && e.status == 401) { window.location = "index.php"; @@ -715,39 +712,25 @@ const Reader = { $("#chapter_pct").text(parseInt(displayed.page / displayed.total * 100) + '%') } - if (Reader.Page._store_position) { - Reader.Page._store_position = 0; - - const lastread_timestamp = new Date().getTime(); - - console.log("storing lastread", currentPct, currentCfi, lastread_timestamp); - - localforage.setItem(Reader.cacheId("lastread"), - {cfi: currentCfi, page: currentPct, total: 100, timestamp: lastread_timestamp}); - - if (new Date().getTime()/1000 - Reader.Page._last_position_sync > 15) { - - if (App.isOnline()) { - console.log("updating remote lastread...") + const lastread_timestamp = new Date().getTime(); - $.post("backend.php", { op: "storelastread", id: $.urlParam("id"), page: currentPct, - cfi: currentCfi, timestamp: lastread_timestamp }, function(data) { + console.log("storing lastread", currentPct, currentCfi, lastread_timestamp); - if (data.cfi) { - Reader.Page._last_position_sync = new Date().getTime()/1000; - } + localforage.setItem(Reader.cacheId("lastread"), + {cfi: currentCfi, page: currentPct, total: 100, timestamp: lastread_timestamp}); - }) - .fail(function(e) { - if (e && e.status == 401) { - window.location = "index.php"; - } - }); + if (App.isOnline()) { + console.log("updating remote lastread...") - } else { - Reader.Page._last_position_sync = 0; - } - } + $.post("backend.php", { op: "storelastread", id: $.urlParam("id"), page: currentPct, + cfi: currentCfi, timestamp: lastread_timestamp }, function() { + // + }) + .fail(function(e) { + if (e && e.status == 401) { + window.location = "index.php"; + } + }); } }); @@ -1117,12 +1100,8 @@ const Reader = { }, }, Page: { - _store_position: 0, - _last_position_sync: 0, _pagination_stored: 0, next: function() { - Reader.Page._store_position = 1; - window.book.rendition.next(); if (typeof EpubeApp != "undefined") |