Работа над ServerStorage, попутный рефакторинг
This commit is contained in:
@@ -208,11 +208,10 @@ class Reader extends Vue {
|
||||
(async() => {
|
||||
await bookManager.init(this.settings);
|
||||
bookManager.addEventListener(this.bookManagerEvent);
|
||||
await this.$refs.serverStorage.init();
|
||||
|
||||
if (this.$root.rootRoute == '/reader') {
|
||||
if (this.routeParamUrl) {
|
||||
this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos});
|
||||
await this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos});
|
||||
} else {
|
||||
this.loaderActive = true;
|
||||
}
|
||||
@@ -290,13 +289,22 @@ class Reader extends Vue {
|
||||
}
|
||||
|
||||
bookManagerEvent(eventName) {
|
||||
const serverStorage = this.$refs.serverStorage;
|
||||
if (eventName == 'load-meta-finish') {
|
||||
serverStorage.init();
|
||||
}
|
||||
|
||||
if (eventName == 'recent-changed') {
|
||||
(async() => {
|
||||
const oldBook = this.mostRecentBookReactive;
|
||||
const newBook = bookManager.mostRecentBook();
|
||||
|
||||
if (oldBook && newBook && oldBook.key != newBook.key) {
|
||||
this.loadBook(newBook);
|
||||
await this.loadBook(newBook);
|
||||
}
|
||||
|
||||
await serverStorage.saveRecent();
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,7 +657,7 @@ class Reader extends Vue {
|
||||
return result;
|
||||
}
|
||||
|
||||
loadBook(opts) {
|
||||
async loadBook(opts) {
|
||||
if (!opts || !opts.url) {
|
||||
this.mostRecentBook();
|
||||
return;
|
||||
@@ -668,7 +676,9 @@ class Reader extends Vue {
|
||||
}
|
||||
|
||||
this.progressActive = true;
|
||||
this.$nextTick(async() => {
|
||||
|
||||
await this.$nextTick()
|
||||
|
||||
const progress = this.$refs.page;
|
||||
|
||||
this.actionList = [];
|
||||
@@ -756,12 +766,13 @@ class Reader extends Vue {
|
||||
this.loaderActive = true;
|
||||
this.$alert(e.message, 'Ошибка', {type: 'error'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadFile(opts) {
|
||||
async loadFile(opts) {
|
||||
this.progressActive = true;
|
||||
this.$nextTick(async() => {
|
||||
|
||||
await this.$nextTick();
|
||||
|
||||
const progress = this.$refs.page;
|
||||
try {
|
||||
progress.show();
|
||||
@@ -773,13 +784,12 @@ class Reader extends Vue {
|
||||
|
||||
progress.hide(); this.progressActive = false;
|
||||
|
||||
this.loadBook({url});
|
||||
await this.loadBook({url});
|
||||
} catch (e) {
|
||||
progress.hide(); this.progressActive = false;
|
||||
this.loaderActive = true;
|
||||
this.$alert(e.message, 'Ошибка', {type: 'error'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
blinkCachedLoadMessage() {
|
||||
|
||||
@@ -107,6 +107,7 @@ class BookManager {
|
||||
}
|
||||
await bmCacheStore.setItem('books', this.booksCached);
|
||||
await bmCacheStore.setItem('recent', this.recent);
|
||||
this.emit('load-meta-finish');
|
||||
}
|
||||
|
||||
async cleanBooks() {
|
||||
|
||||
Reference in New Issue
Block a user