summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-03-14 12:33:22 +0300
committerAndrew Dolgov <[email protected]>2019-03-14 12:33:22 +0300
commitdeab81b4479bdfc9cc798f55b5934c71a0f38f9a (patch)
tree7d8a78f154870cb005a5787cb44d53cbe7b12a15
parent6d814be641fbde0f8a24901332cec34fabc93d77 (diff)
chain startup localforage requests
-rwxr-xr-xreader.js75
1 files changed, 37 insertions, 38 deletions
diff --git a/reader.js b/reader.js
index bf2ae58..806a11d 100755
--- a/reader.js
+++ b/reader.js
@@ -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);
+ }
+ });
});
});