diff options
author | Andrew Dolgov <[email protected]> | 2019-03-14 12:33:22 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-03-14 12:33:22 +0300 |
commit | deab81b4479bdfc9cc798f55b5934c71a0f38f9a (patch) | |
tree | 7d8a78f154870cb005a5787cb44d53cbe7b12a15 | |
parent | 6d814be641fbde0f8a24901332cec34fabc93d77 (diff) |
chain startup localforage requests
-rwxr-xr-x | reader.js | 75 |
1 files changed, 37 insertions, 38 deletions
@@ -123,24 +123,23 @@ function Model() { localforage.setItem("TTC:LAST-OPENED-FILE", file).then(() => { self.mruList(file); - self.fileName(file.split(/[\\/]/).pop()); localforage.getItem(model.cacheKey("SINGLE-COLUMN")).then((single) => { model.singleColumn(single); - }); - localforage.getItem(model.cacheKey("FLIP-COLUMNS")).then((flip) => { - model.flipColumns(flip); - }); + localforage.getItem(model.cacheKey("FLIP-COLUMNS")).then((flip) => { + model.flipColumns(flip); + }); - localforage.getItem(self.cacheKey("POSITION")).then((page) => { - if (page) - self.currentPage(page); - else - self.currentPage(0); + localforage.getItem(self.cacheKey("POSITION")).then((page) => { + if (page) + self.currentPage(page); + else + self.currentPage(0); - self.isLoading(false); + self.isLoading(false); + }); }); }); @@ -330,21 +329,6 @@ const model = new Model(); $(document).ready(function () { const { remote, ipcRenderer } = require('electron'); - localforage.getItem("TTC:SYNC-ACCOUNT").then((acct) => { - if (acct) - model.syncAccount(acct); - }); - - localforage.getItem("TTC:FIT-TO-WIDTH").then((ftw) => { - model.fitToWidth(ftw); - }); - - localforage.getItem("TTC:THEME").then((theme) => { - model.themeName(theme); - }); - - ko.applyBindings(model, document.querySelector('html')); - ipcRenderer.on("open-settings", () => { $('#settings-modal').modal('show'); }); @@ -538,20 +522,35 @@ $(document).ready(function () { } }); - localforage.getItem("TTC:MRU-LIST").then((mru) => { - if (mru != null) - $.each(mru, (i,e) => { - model._mruList.push(e); - }); + localforage.getItem("TTC:SYNC-ACCOUNT").then((acct) => { + if (acct) + model.syncAccount(acct); - localforage.getItem("TTC:LAST-OPENED-FILE").then((last) => { - const argv = remote.process.argv; + localforage.getItem("TTC:FIT-TO-WIDTH").then((ftw) => { + model.fitToWidth(ftw); + }); - if (argv[1] && argv[1] != ".") { - model.openFile(argv[1]); - } else if (last != null) { - model.openFile(last); - } + localforage.getItem("TTC:THEME").then((theme) => { + model.themeName(theme); + }); + + ko.applyBindings(model, document.querySelector('html')); + + localforage.getItem("TTC:MRU-LIST").then((mru) => { + if (mru != null) + $.each(mru, (i,e) => { + model._mruList.push(e); + }); + + localforage.getItem("TTC:LAST-OPENED-FILE").then((last) => { + const argv = remote.process.argv; + + if (argv[1] && argv[1] != ".") { + model.openFile(argv[1]); + } else if (last != null) { + model.openFile(last); + } + }); }); }); |