diff options
author | Andrew Dolgov <[email protected]> | 2019-03-14 10:13:23 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-03-14 10:13:23 +0300 |
commit | ba0a081321083b4b111916939dcfe1af99911bab (patch) | |
tree | 8ee0ce373f78aaf60e084287e87253dba28770d9 | |
parent | 48fb2c4127c5669223086ae61688381dd3f9b1a5 (diff) |
open zip in a timeout so that loading shows properly
-rwxr-xr-x | reader.js | 58 |
1 files changed, 31 insertions, 27 deletions
@@ -88,46 +88,50 @@ function Model() { self._zipEntries.removeAll(); self.currentPage(-2); - const AdmZip = require('adm-zip'); - self._zip = new AdmZip(file); + window.setTimeout(() => { + + const AdmZip = require('adm-zip'); + self._zip = new AdmZip(file); - const zipEntries = self._zip.getEntries(); + const zipEntries = self._zip.getEntries(); - for (let i = 0; i < zipEntries.length; i++) { - const ze = zipEntries[i]; + for (let i = 0; i < zipEntries.length; i++) { + const ze = zipEntries[i]; - if (ze.entryName.match(/\.(jpe?g|gif|bmp|png|webp)$/i)) { - self._zipEntries.push(ze); + if (ze.entryName.match(/\.(jpe?g|gif|bmp|png|webp)$/i)) { + // prevent observer events (?) - open faster + self._zipEntries().push(ze); + } } - } - self._zipEntries.sort(function(a, b) { - return a.entryName.localeCompare(b.entryName); - }); + self._zipEntries.sort(function(a, b) { + return a.entryName.localeCompare(b.entryName); + }); - localforage.setItem('LAST-OPENED-FILE', file).then(() => { - self.mruList(file); + localforage.setItem('LAST-OPENED-FILE', file).then(() => { + self.mruList(file); - self.fileName(file.split(/[\\/]/).pop()); + self.fileName(file.split(/[\\/]/).pop()); - localforage.getItem(model.cacheKey("SINGLE-COLUMN")).then((single) => { - model.singleColumn(single); - }); + 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); + }); }); - }); + }, 100); }; self.documentTitle = ko.computed(function () { |