Добавление событий, рефакторинг

This commit is contained in:
Book Pauk
2019-03-20 14:57:40 +07:00
parent b12198fdcf
commit 090ffa9921
3 changed files with 21 additions and 11 deletions

View File

@@ -207,6 +207,7 @@ class Reader extends Vue {
mounted() {
(async() => {
await bookManager.init(this.settings);
bookManager.addEventListener(this.bookManagerEvent);
await this.$refs.serverStorage.init();
if (this.$root.rootRoute == '/reader') {
@@ -288,6 +289,17 @@ class Reader extends Vue {
this.debouncedUpdateRoute();
}
bookManagerEvent(eventName) {
if (eventName == 'recent-changed') {
const oldBook = this.mostRecentBookReactive;
const newBook = bookManager.mostRecentBook();
if (oldBook && newBook && oldBook.key != newBook.key) {
this.loadBook(newBook);
}
}
}
get toolBarActive() {
return this.reader.toolBarActive;
}