diff options
author | Andrew Dolgov <[email protected]> | 2018-06-29 18:14:27 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-06-29 18:14:27 +0300 |
commit | f738e738eb2a353498da91272c565eb44d0d6250 (patch) | |
tree | d8f9703a8d3cec95ac20b1e7296a3cdb03af6565 | |
parent | cad12aef84254da925f793a0eb54c5cee06d0fd0 (diff) |
fix issues with splash not always hiding if open_lastread() fails on startup
-rw-r--r-- | js/read.js | 15 | ||||
-rw-r--r-- | read.html | 5 |
2 files changed, 15 insertions, 5 deletions
@@ -38,7 +38,12 @@ function open_lastread() { item = item || {}; - if (item.cfi) book.rendition.display(item.cfi); + // CFI missing or w/e + try { + if (item.cfi) book.rendition.display(item.cfi); + } catch (e) { + console.warn(e); + } if (navigator.onLine) { @@ -49,8 +54,12 @@ function open_lastread() { localforage.setItem(cacheId("lastread"), {cfi: data.cfi, page: data.page, total: data.total}); - if (item.cfi != data.cfi && (!item.page || data.page > item.page)) - book.rendition.display(data.cfi); + try { + if (item.cfi != data.cfi && (!item.page || data.page > item.page)) + book.rendition.display(data.cfi); + } catch (e) { + console.warn(e); + } } }); @@ -705,6 +705,9 @@ }); open_lastread(); + + $(".loading").hide(); + }); rendition.on("keyup", hotkey_handler); @@ -776,8 +779,6 @@ if (book.locations.length() == 0) return; - $(".loading").hide(); - var currentCfi = location.start.cfi; var currentPage = parseInt(book.locations.percentageFromCfi(currentCfi) * 100); var pct = book.locations.percentageFromCfi(currentCfi); |