Поправка бага

This commit is contained in:
Book Pauk
2019-02-28 15:20:20 +07:00
parent 0d61f5523a
commit ca47d9272c

View File

@@ -17,7 +17,6 @@ const bmRecentStore = localForage.createInstance({
name: 'bmRecentStore' name: 'bmRecentStore'
}); });
//bmCacheStore нужен только для ускорения загрузки читалки
const bmCacheStore = localForage.createInstance({ const bmCacheStore = localForage.createInstance({
name: 'bmCacheStore' name: 'bmCacheStore'
}); });
@@ -26,7 +25,6 @@ class BookManager {
async init(settings) { async init(settings) {
this.settings = settings; this.settings = settings;
//bmCacheStore нужен только для ускорения загрузки читалки
this.booksCached = await bmCacheStore.getItem('books'); this.booksCached = await bmCacheStore.getItem('books');
if (!this.booksCached) if (!this.booksCached)
this.booksCached = {}; this.booksCached = {};
@@ -49,7 +47,9 @@ class BookManager {
} }
} }
//долгая загрузка из хранилища
//bmMetaStore и bmRecentStore в будущем можно будет убрать
//bmCacheStore достаточно
async loadMeta(immediate) { async loadMeta(immediate) {
if (!immediate) if (!immediate)
await utils.sleep(2000); await utils.sleep(2000);
@@ -62,7 +62,13 @@ class BookManager {
if (keySplit.length == 2 && keySplit[0] == 'bmMeta') { if (keySplit.length == 2 && keySplit[0] == 'bmMeta') {
let meta = await bmMetaStore.getItem(key); let meta = await bmMetaStore.getItem(key);
const oldBook = this.books[meta.key];
this.books[meta.key] = meta; this.books[meta.key] = meta;
if (oldBook && oldBook.data && oldBook.parsed) {
this.books[meta.key].data = oldBook.data;
this.books[meta.key].parsed = oldBook.parsed;
}
} }
} }